0353: "Python"

This forum is for the individual discussion thread that goes with each new comic.

Moderators: Moderators General, Prelates, Magistrates

User avatar
tetsujin
Posts: 426
Joined: Thu Nov 15, 2007 8:34 pm UTC
Location: Massachusetts
Contact:

Re: "Python" discussion

Postby tetsujin » Tue Dec 11, 2007 11:38 pm UTC

rqm wrote:
fortyseventeen wrote:I thought Ruby was the younger cousin


It is, but Matz (Ruby's creator) invented the "Principle of least surprise", for instance, Ruby implements the same method under different names (aka synonyms) like 'length' and 'size'. The idea is that if you type length or size the code still works, but I think a newcomer that reads 'size' and 'length' in different example code will be left wondering what the difference is until he reads the documentation. So what languages contains less surprises? In addition I can only imagine synonyms must make monkey patching a lot more *fun*.


Huh. I thought the "Principle of least surprise" was supposed to mean that, once you learned Ruby you'd find that its level of self-consistency would tend to not surprise you... What you're describing sounds more like Perl's "There's more than one way to do it."
---GEC
I want to create a truly new command-line shell for Unix.
Anybody want to place bets on whether I ever get any code written?

User avatar
rqm
Posts: 42
Joined: Wed Dec 05, 2007 7:30 pm UTC
Location: Mars
Contact:

Re: "Python" discussion

Postby rqm » Wed Dec 12, 2007 12:34 am UTC

tetsujin wrote:Huh. I thought the "Principle of least surprise" was supposed to mean that, once you learned Ruby you'd find that its level of self-consistency would tend to not surprise you... What you're describing sounds more like Perl's "There's more than one way to do it."


Well generally, Ruby tries to, and usually achieves to give you as few surprises as possible, Python tries too.

mjkuhlman2000
Posts: 4
Joined: Thu Dec 13, 2007 12:13 am UTC
Location: USA

Re: "Python" discussion

Postby mjkuhlman2000 » Thu Dec 13, 2007 1:02 am UTC

segmentation fault wrote:language isnt a matter of choice, you use whats best for the job.


Is this becoming a war about which programming language is best? Has anyone said anything about MATLAB? I personally was never a fan of programming until I came across Python and MATLAB, both of which I used for a summer internship. After using C for a few years, picking up Python was a piece of cake, and it's incredibly useful for a lot of 3D applications. My Perl book is still sitting on my shelf collecting dust.

When it comes down to analyzing numbers quickly, I say MATLAB is the best. Name another programming environment that has built-in methods (plot, imshow) to visualize data. Then again, MATLAB isn't free....

User avatar
DragonHawk
Posts: 457
Joined: Sat Sep 15, 2007 1:20 am UTC
Location: NH, US, Earth
Contact:

Re: "Python" discussion

Postby DragonHawk » Thu Dec 13, 2007 2:37 am UTC

mjkuhlman2000 wrote:Name another programming environment that has built-in methods (plot, imshow) to visualize data.

LabVIEW, MathCAD, HTBASIC... there's quite a few, really. But they're pretty much all proprietary. There's not much in the way of open standards for such. Interesting.
Ben'); DROP TABLE Users;--

GENERATION 42: The first time you see this, copy it into yοur sig on any forum and stick a fork in yοur еyе. Social experiment.

magnum_opus
Posts: 14
Joined: Sun Nov 05, 2006 2:25 am UTC

Re: "Python" discussion

Postby magnum_opus » Fri Dec 14, 2007 12:13 am UTC

DragonHawk wrote:
mjkuhlman2000 wrote:Name another programming environment that has built-in methods (plot, imshow) to visualize data.

LabVIEW, MathCAD, HTBASIC... there's quite a few, really. But they're pretty much all proprietary. There's not much in the way of open standards for such. Interesting.


as for open source
R
Rlab (now rlabplus)
SciLab (i doubt it's OSI approved but it distributes source and lets you distribute certain modified versions)
Octave (matlab clone)
Yorick
Gnu Data Language (IDL clone)

just off the top of my head

theres also
Ox
ch
on the proprietary but less known side.

steve.howard
Posts: 6
Joined: Wed Oct 24, 2007 9:06 am UTC

Re: "Python" discussion

Postby steve.howard » Fri Dec 14, 2007 2:52 am UTC

Just thought I'd mention to Pythoners who didn't notice/don't subscribe to python-announce...

This comic was featured in this week's Python-URL! - both in the Quote of the Week and the body of the posting:

http://mail.python.org/pipermail/python ... 06295.html

Whee! XKCD + Python = made my day... several times.

User avatar
OmenPigeon
Peddler of Gossamer Lies
Posts: 673
Joined: Mon Sep 25, 2006 6:08 am UTC
Contact:

Re: "Python" discussion

Postby OmenPigeon » Fri Dec 14, 2007 3:11 am UTC

mjkuhlman2000 wrote:Name another programming environment that has built-in methods (plot, imshow) to visualize data. Then again, MATLAB isn't free....

I've seen some nice Python libraries to do the same sort of stuff MATLAB does. I haven't used them much myself, but from reading a little code it seems like all you have to do is load some numbers into fairly simple data structure then call a chart-generating method or two, and it pops up some graphs.

Nothing all that pretty, at least by default, but enough to get the job done. Especially by the masochistic design standards of academia.
As long as I am alive and well I will continue to feel strongly about prose style, to love the surface of the earth, and to take pleasure in scraps of useless information.
~ George Orwell

cheeze
Posts: 2
Joined: Wed Nov 28, 2007 12:18 am UTC
Location: University of Illinois at Urbana-Champaign

Re: "Python" discussion

Postby cheeze » Fri Dec 14, 2007 7:51 am UTC

Haha. When I read this, I was just like .. bout time. :p

User avatar
FractalNinja
Posts: 22
Joined: Tue Nov 27, 2007 1:42 am UTC

Re: "Python" discussion

Postby FractalNinja » Sat Dec 15, 2007 7:36 pm UTC

ImportAntigravity.jpg
Import Antigravity
ImportAntigravity.jpg (137.6 KiB) Viewed 9391 times


Yeah, I was bored of writing these stupid college apps, so I took a break and learned enough python to write the module. It wont let me attach the module, so I'll just include the code:

Code: Select all

# Antigravity Module

def fly():
    print "Now you can fly! Just like the ferret!"
    print "..."
    print "But maybe it's just all that stuff from the medicine cabinet..."

def wtf():
    print "www.xkcd.com/353"
    print "READ IT."
Image
My Psychobilly Radio Station

Lathe
Posts: 47
Joined: Fri Nov 30, 2007 8:36 pm UTC

Re: "Python" discussion

Postby Lathe » Sat Dec 15, 2007 7:47 pm UTC

Unforgiven wrote: ... without knowing one iota about the underlying mechanics.

In C, that would have been "...without knowing one itoa..."

User avatar
r1chard
Posts: 281
Joined: Thu Dec 06, 2007 2:17 am UTC
Location: Melbourne, AU
Contact:

Re: "Python" discussion

Postby r1chard » Sun Dec 16, 2007 12:24 am UTC

FractalNinja wrote:

Code: Select all

# Antigravity Module

def fly():
    print "Now you can fly! Just like the ferret!"
    print "..."
    print "But maybe it's just all that stuff from the medicine cabinet..."

def wtf():
    print "www.xkcd.com/353"
    print "READ IT."


A small improvement:

Code: Select all

def wtf():
    import webbrowser
    webbrowser.open("http://www.xkcd.com/353")
    print "READ IT."

User avatar
FractalNinja
Posts: 22
Joined: Tue Nov 27, 2007 1:42 am UTC

Re: "Python" discussion

Postby FractalNinja » Mon Dec 17, 2007 11:39 pm UTC

r1chard wrote:A small improvement:

Code: Select all

def wtf():
    import webbrowser
    webbrowser.open("http://www.xkcd.com/353")
    print "READ IT."


Thanks, that's a good idea. I didn't read on to the webbrowser module until later that day.
Image
My Psychobilly Radio Station

keflavich
Posts: 2
Joined: Wed Dec 05, 2007 5:49 am UTC
Location: Boulder

Re: "Python" discussion

Postby keflavich » Tue Dec 18, 2007 9:19 pm UTC

magnum_opus wrote:
DragonHawk wrote:
mjkuhlman2000 wrote:Name another programming environment that has built-in methods (plot, imshow) to visualize data.

LabVIEW, MathCAD, HTBASIC... there's quite a few, really. But they're pretty much all proprietary. There's not much in the way of open standards for such. Interesting.


as for open source
R
Rlab (now rlabplus)
SciLab (i doubt it's OSI approved but it distributes source and lets you distribute certain modified versions)
Octave (matlab clone)
Yorick
Gnu Data Language (IDL clone)

just off the top of my head

theres also
Ox
ch
on the proprietary but less known side.


More open source within python and perl:
python has numpy/numarray and pylab, which has a syntax very similar to matlab (it uses the "matplotlib" module)
perl has pdl, perl data language, which runs on PGPLOT and is a pain to install but it works nicely

RaptorAttack
Posts: 37
Joined: Thu Dec 20, 2007 8:47 pm UTC

Re: "Python" discussion

Postby RaptorAttack » Fri Dec 21, 2007 5:35 am UTC

I've been seeing all this discussion of Python and Ruby and C - what do you guys think of PHP, if you have used it?

I'm kind of a newbie to programming and graduated with a liberal arts degree, but I've discovered that (at least to some extent) I enjoy messing with computer related stuff. I'm using Ubuntu (newbie Linux I guess?) and got interested in web development, so learned HTML and CSS, and then started playing with Javascript, and lately I've been doing a lot of PHP (and MySQL), and toying around with Apache and how it runs things.

I find it really interesting to be able to make dynamic website content, load things into and out of databases, that kind of thing. I have recently started understanding a lot of PHP's security related issues, although these mostly seem preventable. There are also other annoying things about PHP - for instance, I've been trying to make decent user login and session tracking systems, but for some reason sessions don't seem to last as long as they should, which I've been finding can be related to various annoying settings and interference from PHP's configuration.

Anyway sorry for rambling, I guess I thought I'd ask for some opinions on that. And, if I want to continue looking into web development and hope to get a job, but feel like I need a broader understanding of it, is there some particular language or area that would be a good idea to focus on? I.E. would learning a more complex language like C be helpful or mostly unrelated?

benizi
Posts: 3
Joined: Sat Dec 22, 2007 7:45 am UTC

Re: "Python" discussion

Postby benizi » Sat Dec 22, 2007 8:58 am UTC

Aww. The alt= text made me sad. (Big fan of LISP (XKCD 224).) Especially because I've been writing XKCD-inspired obfuscated code the past week or so.

I haven't looked at Python since a few versions ago. Part of what I like about Perl is its slow linguistic development. Contrast that with Java in particular, where learning it at v.1.2 got me virtually nowhere when coming back to 1.6(?) or whatever they're on. But what really gets me is one-liners. I do soooo many things from the command line that I just can't switch to Python. Ruby, maybe. But I like the denseness of Perl.

Here's a histogram of my shell history grouped by length of program:

Code: Select all

N       ~10**(N/3)   #of command lines that long
1       2            6
2       4            69
3       10           1330
4       21           1954
5       46           2145
6       100          1648
7       215          629
8       464          90


Most of the longest ones are iterative, of course, refined over much line-editing. But even that histogram came from a Perl "one-liner":

Code: Select all

fc -n -l 0 | perl -lnwe 'next unless /^perl(?:\s-\S+)*e\s*([\x27\"])(.*?)\1/; my $l = length $2; next unless $l; print join "\t", $l, int log($l)/log(10**(1/3)), $2' | sort -n | less


For anything where someone else might have to maintain the code, though... :-)

Even working with only one other programmer can get pretty hairy. It's so hard to enforce style in Perl.

The main advantage I saw in Python was speed. When I learned it, the first non-trivial thing I did was to convert my WordNet Perl module to a Python {class/library/whatever}. I did a pretty straightforward conversion, so it probably wasn't very Python-y, but it was already twice as fast as the Perl.

Tried not to cross the "religious wars" line here. Just felt like replying after catching up on my XKCD after a bit of a hiatus.

Later,
Ben

User avatar
M.qrius
Rainbow Brite
Posts: 519
Joined: Sat Nov 10, 2007 12:54 am UTC
Location: Rainbow's end
Contact:

Re: "Python" discussion

Postby M.qrius » Mon Dec 31, 2007 8:57 pm UTC

If you're actually going for speed, python probably isn't the optimal choice though. It's not known for its speed.
It is pretty good at oneliners though, with all the list comprehension, lambda function (mapping), etc. It's probably possible to do what you just did in python, if I knew how to easily get the previous commands of a shell and things like that.

That said, python is nice. *jumps out of window*

User avatar
jekbradbury
Posts: 11
Joined: Mon Nov 26, 2007 2:10 am UTC
Location: McLean VA

Re: "Python" discussion

Postby jekbradbury » Mon Dec 31, 2007 9:14 pm UTC

For those who think that MATLAB is the best numerical software: try the free SAGE (http://www.sagemath.org). It bundles together many of the aforementioned open-source packages with Python as the interface language. Best of both worlds at its best. It even has an online demo and two web interface servers so you don't even have to install it. It is the most open-source of anything I have ever seen: just type two question marks after any function and it gives you the Python source.

CAVEATS: local version runs only on Unix so the Windows version is actually a 3 GB VMWare disk image plus the VMWare Player. Web version is (currently) uber slow due to /.ing. Documentation is orders of magnitude worse than Mathematica or Maple or MATLAB.

User avatar
jekbradbury
Posts: 11
Joined: Mon Nov 26, 2007 2:10 am UTC
Location: McLean VA

Re: "Python" discussion

Postby jekbradbury » Tue Jan 01, 2008 3:49 pm UTC

Actually, I hadn't checked in a while; the online version is fast again.

Tesiph
Posts: 1
Joined: Wed Jan 02, 2008 9:30 pm UTC

Re: "Python" discussion

Postby Tesiph » Wed Jan 02, 2008 9:49 pm UTC

hotaru wrote:i'll learn python when it can do this in as few lines:

Code: Select all

my@mname=('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
for(grep/\/\d+\.(?:gif|jpg|png)$/,map{glob"$_/*"}@ARGV){
 (my$newname=$_)=~s/(\d+)...(....)$/${\((gmtime$1)[5]+1900)}${\($mname[(gmtime$1)[4]])}${\((gmtime$1)[3])}-${\(join'.',map{0 x($_<10).$_}reverse map{(gmtime$1)[$_]}0..2)}$2/;
  rename$_,$newname;
}

WTF does it even do?
I have nothing against Perl, but hey, I have some free time reserved to meaninglessly argue on the internet:

Code: Select all

import time, os, os.path, sys, re
for dn in [(x, os.listdir(x)) for x in sys.argv[1:]]:
    for fn in filter(lambda z: re.match(r'\d+\.(gif|jpg|png)', z), dn[1]):
        newname = time.strftime('%Y%b%d-%H.%M.%S', time.gmtime(float(os.path.splitext(fn)[0]))) + os.path.splitext(fn)[1]
        os.rename(*map(lambda a: os.path.abspath(os.path.join(dn[0], a)), [fn, newname])) # This could be called abuse of syntax
Good luck; Python is a fun language.

User avatar
M.qrius
Rainbow Brite
Posts: 519
Joined: Sat Nov 10, 2007 12:54 am UTC
Location: Rainbow's end
Contact:

Re: "Python" discussion

Postby M.qrius » Wed Jan 02, 2008 9:52 pm UTC

Tesiph wrote:

Code: Select all

import time, os, os.path, sys, re
for dn in [(x, os.listdir(x)) for x in sys.argv[1:]]:
    for fn in filter(lambda z: re.match(r'\d+\.(gif|jpg|png)', z), dn[1]):
        newname = time.strftime('%Y%b%d-%H.%M.%S', time.gmtime(float(os.path.splitext(fn)[0]))) + os.path.splitext(fn)[1]
        os.rename(*map(lambda a: os.path.abspath(os.path.join(dn[0], a)), [fn, newname])) # This could be called abuse of syntax
Good luck; Python is a fun language.

Awesome :D
Did you use a converter, or did you translate it yourself without knowing what it does?

User avatar
levicc00123
Posts: 165
Joined: Thu Jan 03, 2008 5:33 pm UTC
Location: Sterling, CO
Contact:

Re: "Python" discussion

Postby levicc00123 » Thu Jan 03, 2008 5:41 pm UTC

I use python for most of my projects, it's the first language I learned and used, I love it.
Image

User avatar
segmentation fault
Posts: 1770
Joined: Wed Dec 05, 2007 4:10 pm UTC
Location: Nu Jersey
Contact:

Re: "Python" discussion

Postby segmentation fault » Thu Jan 03, 2008 6:54 pm UTC

talk about syntactic sugar...
people are like LDL cholesterol for the internet

User avatar
fennecfanatic
Posts: 30
Joined: Thu Jan 03, 2008 7:24 pm UTC
Location: Vulcan sector
Contact:

Re: "Python" discussion

Postby fennecfanatic » Thu Jan 03, 2008 7:57 pm UTC

I'm a tester and Python developer attached to a speech applications group which primarily works in C#. From my experiences so far, I like both languages quite a lot.

Registered just to post here. Someone explained "monkeypatching" in Python, and I appreciate the insight! I've been trying unsuccessfully to glue packet-level methods into socket objects for convenience for some time.

Now, the logical person would say, "Why Kate (being my name), why don't you just subclass socket?"

They'd suggest something like

Code: Select all

import socket
import struct
class my_socket(socket.socket):
    def send_packet( self, packet_data ):
        self.send( struct.pack( '>I', len(packet_data) ) + packet_data
    def recv_packet( self ):
        return self.recv( struct.unpack( '>I', self.recv(4) )[0] )


And this would indeed work, but the accept method of the socket class returns a socket object (and an address, port tuple), so I'd lose my shiny new methods after connecting.

The solution, of course, is to patch the socket class to add the functionality. It's a hack, but it works!

(For those not in the know, struct.pack and unpack are used to convert an integer here to a four-byte string in big-endian format (the '>' means big-endian, the 'I' means unsigned int)

So thank you!

As for normal multiple inheritance and mix-ins, this is a very typical practice in Python, and I don't see why people are confused about it...

Multiple inheritance:

Code: Select all

class A:
    def bar(self):
        print 'bar'

class B:
    def foo(self):
        print 'foo'

class C(A, B):
    pass

# Interpreter --
>>> c = C()
>>> c.foo()
foo
>>> c.bar()
bar


And Mix-Ins:

Code: Select all

import SocketServer

class MySocketServer(SocketServer.TCPServer, SocketServer.ThreadingMixIn):
    pass


That creates a TCP server and mixes in threading methods... Python supports multiple inheritance directly, and is malleable enough that you don't need to mark a distinction between classes, interfaces, and mix-ins, they're all just base classes.

You can duplicate the effects of an interface by just defining some methods and having them raise an exception (so they have to be overridden for the code to work). True, the error will only fire if the method gets called, but why does a method need to be valid if it doesn't get called?

PyChecker is a handy tool to fill the gap left by having an error-checking compiler. It catches a lot of problems which a compiler normally would, although it would require a plugin to support interface enforcement...

Got kind of off topic there. Anyway, I really like Python, and oddly enough I also like C#, which must be at the opposite end of the spectrum, nearly. Heh.

And someone mentioned operator overloading... That's as easy in Python as defining a method. They're specially named in the typical __doubleUnderscores__ fashion:

__mul__ is for *
__add__ is for +
__sub__ is for -
__eq__ is for ==

etc. I have the little O'Reilly Python pocket ref which contains a very helpful list of these as well as a number of other things that are great for quick reference -- regex syntax, for example.

</long-post>
"the crapping out is non-deterministic." (danderson)

User avatar
r1chard
Posts: 281
Joined: Thu Dec 06, 2007 2:17 am UTC
Location: Melbourne, AU
Contact:

Re: "Python" discussion

Postby r1chard » Fri Jan 11, 2008 5:33 am UTC

Tesiph wrote:

Code: Select all

import time, os, os.path, sys, re
for dn in [(x, os.listdir(x)) for x in sys.argv[1:]]:
    for fn in filter(lambda z: re.match(r'\d+\.(gif|jpg|png)', z), dn[1]):
        newname = time.strftime('%Y%b%d-%H.%M.%S', time.gmtime(float(os.path.splitext(fn)[0]))) + os.path.splitext(fn)[1]
        os.rename(*map(lambda a: os.path.abspath(os.path.join(dn[0], a)), [fn, newname])) # This could be called abuse of syntax
Good luck; Python is a fun language.


Any time I see a map/lambda these days, I just itch until I rewrite it using a generator expression (requires Python2.4+ -- use a list comprehension if you're stuck with 2.3):

Code: Select all

os.rename(*(os.path.abspath(os.path.join(dn[0], a)) for a in [fn, newname]))


And FWIW it's not an abuse of syntax :)

jjpr
Posts: 3
Joined: Fri Mar 14, 2008 10:51 pm UTC

Postby jjpr » Fri Mar 14, 2008 11:17 pm UTC

"import antigravity" is a popular meme here at PyCon.

User avatar
Scigatt
Posts: 195
Joined: Sat Dec 23, 2006 11:45 am UTC
Location: Vancouver
Contact:

Re: "Python" discussion

Postby Scigatt » Tue Apr 29, 2008 11:17 am UTC

While I haven't done much programming at all in my life(In my HS electronics class we had to program PIC chips to light up LED in a pattern), I have had moments of seeming crystal-clear thought...or something like that. Most recently, It has come with my discovery of relational interpretation of quantum mechanics(RQM).

zahlman
Posts: 638
Joined: Wed Jan 30, 2008 5:15 pm UTC

Re: "Python" discussion

Postby zahlman » Wed Apr 30, 2008 12:53 am UTC

Tesiph wrote:
hotaru wrote:i'll learn python when it can do this in as few lines:

Code: Select all

my@mname=('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
for(grep/\/\d+\.(?:gif|jpg|png)$/,map{glob"$_/*"}@ARGV){
 (my$newname=$_)=~s/(\d+)...(....)$/${\((gmtime$1)[5]+1900)}${\($mname[(gmtime$1)[4]])}${\((gmtime$1)[3])}-${\(join'.',map{0 x($_<10).$_}reverse map{(gmtime$1)[$_]}0..2)}$2/;
  rename$_,$newname;
}

WTF does it even do?
I have nothing against Perl, but hey, I have some free time reserved to meaninglessly argue on the internet:

Code: Select all

import time, os, os.path, sys, re
for dn in [(x, os.listdir(x)) for x in sys.argv[1:]]:
    for fn in filter(lambda z: re.match(r'\d+\.(gif|jpg|png)', z), dn[1]):
        newname = time.strftime('%Y%b%d-%H.%M.%S', time.gmtime(float(os.path.splitext(fn)[0]))) + os.path.splitext(fn)[1]
        os.rename(*map(lambda a: os.path.abspath(os.path.join(dn[0], a)), [fn, newname])) # This could be called abuse of syntax
Good luck; Python is a fun language.


Why not just use a list comprehension for the last bit?

Anyway, here's my version (following the Perl a bit more closely):

Code: Select all

import re, glob, sys, os, time
for x in sum(glob.glob(y + '/*') for y in sys.argv):
  if not re.match('\/\d+\.(?:gif|jpg|png)$', x): continue
  timestamp, tag = re.match('(\d+)...(....)$', x).groups()
  mytime = time.gmtime(int(timestamp))
  os.rename(x, str(mytime[0]) + ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[mytime[1]] + '%02d.%02d.%02d' % mytime[2:4] + tag)


And an attempted cleanup of yours:

Code: Select all

import time, os, sys, re
from os.path import abspath, splitext, join
for dn in sys.argv[1:]:
    for fn in os.listdir(dn):
        name, ext = splitext(fn)
        if ext in ('gif', 'jpg', 'png'):
            os.rename(*(abspath(join(dn, a) for a in (
                fn,
                time.strftime('%Y%b%d-%H.%M.%S', time.gmtime(float(name[:-3]))) + name[-3:] + ext
            ))) # Generator comprehension, even >:)
Belial wrote:I once had a series of undocumented and nonstandardized subjective experiences that indicated that anecdotal data is biased and unreliable.

pavelludiq
Posts: 12
Joined: Wed May 07, 2008 5:18 pm UTC

Re: "Python" discussion

Postby pavelludiq » Fri May 09, 2008 1:06 pm UTC

This thread has a lot of stupid things in it. I will not comment them, I'll just express my own view on some of the topics discussed here. I like python mainly because its powerful, clean and easy. I think that it's a good idea to know some low level stuff, so i like C too(but don't use it at all, maybe i will, but not unless i have to). I have no opinion on ruby, its good, but i won't bother to learn it because its very similar to python and i don't see any gain in that. It would be a better idea to learn some very different language to see things differently. Plus ruby is not my style, i like python better as a language, if ruby is better(which i don't know) It's still not that much better to like its style(ruby people say similar things). A good programmer has to know many languages to be able to use his favourite one better and to know were its weaknesses are. So far most languages i have looked at(only superficially) seem to be similar or worse than python, or designed for completely different tasks(C being a good example IMO). Anyway I mentioned that i like python because its clean, ruby i think is a little less cleaner, and C i think is prety clean and that's why i like it. That's why i don't like c++ and Java. I'm not going to talk about perl, I'm just not going to use it or learn it any time soon.
In conclusion python kicks ass, ruby probably too, C too(but a diferent kind of ass, this one being made by metal and silicon :D )

RainsWonder
Posts: 2
Joined: Mon May 26, 2008 2:10 am UTC

Re: "Python" discussion

Postby RainsWonder » Mon May 26, 2008 2:48 am UTC


User avatar
thoughtfully
Posts: 2253
Joined: Thu Nov 01, 2007 12:25 am UTC
Location: Minneapolis, MN
Contact:

Re: "Python" discussion

Postby thoughtfully » Wed Aug 13, 2008 5:47 am UTC

Pipian wrote:Seriously, can you define and implement methods in some random file and then mix them seamlessly into any Python class you choose without subclassing and almost implement multiple inheritance? Ruby can.

Yup! You can also use the classobj function the new module to construct a class from a list of parent classes defined at runtime, and then just use setattr() to define new methods.

EDIT: This is equivalent to using the ClassType type from the types module. The new module is deprecated, it would seem.
Image
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

User avatar
a386
Posts: 220
Joined: Fri Nov 09, 2007 5:07 pm UTC
Location: sailing the seas
Contact:

Re: "Python" discussion

Postby a386 » Fri Jul 10, 2009 3:53 am UTC

i just started reading buttercup festival and it brought this comic to mind. i love little visual references like this, the way the sky is drawn here. woooo!

Anonymously Famous
Posts: 242
Joined: Thu Nov 18, 2010 4:01 am UTC

Re: 0353: "Python"

Postby Anonymously Famous » Thu Nov 18, 2010 4:15 am UTC

I recently started reading XKCD. Clicking on "Random" has become a habit of mine.

This led me to comic #353: Python.

Which led me to learning a little bit about python and downloading Python 2.7 for Windows.

One of the first things I did was type "import antigravity".

And it does something. "antigravity" is included in the library.

Awesome.

webgiant
Posts: 252
Joined: Mon Aug 17, 2009 5:36 pm UTC

Re: 0353: "Python"

Postby webgiant » Fri Nov 19, 2010 2:35 am UTC

Anonymously Famous wrote:I recently started reading XKCD. Clicking on "Random" has become a habit of mine.

This led me to comic #353: Python.

Which led me to learning a little bit about python and downloading Python 2.7 for Windows.

One of the first things I did was type "import antigravity".

And it does something. "antigravity" is included in the library.

Awesome.

Yup, the developers thought of everything.

User avatar
Robert'); DROP TABLE *;
Posts: 730
Joined: Mon Sep 08, 2008 6:46 pm UTC
Location: in ur fieldz

Re: 0353: "Python"

Postby Robert'); DROP TABLE *; » Fri Nov 19, 2010 3:45 pm UTC

What's even less obvious is that the antigravity module includes a geohasing algorithm.
...And that is how we know the Earth to be banana-shaped.

Mooglefrooglian
Posts: 19
Joined: Wed Mar 10, 2010 1:06 am UTC

Re: 0353: "Python"

Postby Mooglefrooglian » Sat Nov 20, 2010 5:40 am UTC

Ruby. Everything from getters/setters to operator overloading is a joy. Dynamically adding methods to a class? Yes, please! Not that I don't like python, it's just that it's more the middle child.

Also, C# beats Java in pretty much every way excepting support those few, unknown, mythical OSes that no one really cares about. Properties > inconsistent fields/methods (or, better summed up, .Length > .length(), .length, .getLength()). Also, Visual Studio.

User avatar
Otto
Posts: 22
Joined: Fri Oct 12, 2007 8:30 pm UTC

Re: "Python" discussion

Postby Otto » Wed Dec 08, 2010 6:19 am UTC

segmentation fault wrote:
Otto wrote:The thing language aficionados often seem to miss is that the language is just a matter of choice.

language isnt a matter of choice, you use whats best for the job.


The language that is best for the job is the one that you use to get the job done. Until you understand this, you cannot truly master the Tao.

Skahizzles
Posts: 1
Joined: Mon Dec 27, 2010 5:13 am UTC

Re: 0353: "Python"

Postby Skahizzles » Mon Dec 27, 2010 5:21 am UTC

Greetings to those of the xkcd fora, I've been reading for a while, but haven't posted until now.

Recently this comic inspired me to learn python, but with little programming background, I was a bit lost. As soon as I opened Idle and the Python shell, I entered the commands listed in this comic and, lo and behold, I found an easter egg.

The command "import antigravity" opens an in browser link to this comic. Has anyone else noticed this?

User avatar
thoughtfully
Posts: 2253
Joined: Thu Nov 01, 2007 12:25 am UTC
Location: Minneapolis, MN
Contact:

Re: 0353: "Python"

Postby thoughtfully » Mon Dec 27, 2010 1:35 pm UTC

Yes, that's been a feature of Python3 for quite awhile, maybe since the first release. I just wish they'd backport it to the 2.x series :)
Ahh, n/m. I see it's in v2.7 now. Sweet!
Image
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

User avatar
Tiggydong
Posts: 12
Joined: Sun Sep 21, 2008 11:33 am UTC
Contact:

Re: 0353: "Python"

Postby Tiggydong » Tue Jun 21, 2011 8:56 pm UTC

I know I'm ridiculously late, but we've just been told to learn python for next years course, so of course the first thing I try is "import antigravity" :D
Ahh, it made me happy :)

User avatar
SirMustapha
Posts: 1302
Joined: Mon Jul 21, 2008 6:07 pm UTC

Re: 0353: "Python"

Postby SirMustapha » Tue Jun 21, 2011 10:04 pm UTC

Anonymously Famous wrote:I recently started reading XKCD. Clicking on "Random" has become a habit of mine.

This led me to comic #353: Python.

Which led me to learning a little bit about python and downloading Python 2.7 for Windows.

One of the first things I did was type "import antigravity".

And it does something. "antigravity" is included in the library.

Awesome.


Skahizzles wrote:Greetings to those of the xkcd fora, I've been reading for a while, but haven't posted until now.

Recently this comic inspired me to learn python, but with little programming background, I was a bit lost. As soon as I opened Idle and the Python shell, I entered the commands listed in this comic and, lo and behold, I found an easter egg.

The command "import antigravity" opens an in browser link to this comic. Has anyone else noticed this?


Tiggydong wrote:I know I'm ridiculously late, but we've just been told to learn python for next years course, so of course the first thing I try is "import antigravity" :D
Ahh, it made me happy :)


I can understand not wading through six pages of years-old discussions, but reading the last page, at least... It's not that hard, is it?


Return to “Individual XKCD Comic Threads”

Who is online

Users browsing this forum: Majestic-12 [Bot], typo and 83 guests