Search the web
Sign In
New User? Sign Up
perl-python
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 1 - 30 of 127   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Simplify | Expand   (Group by Topic) Author Sort by Date ^
1
# -*- coding: utf-8 -*- # python supports unicode in source code by putting a coding declaration # as the first line. print "look chinese chars:...
xah lee
p0lyglut
Offline Send Email
Jan 9, 2005
8:22 am
2
#python supports complex numbers. # append a "j" to a number and it represents the imaginary number. e.g. # 3j means 3*i. #(3,4) can be written as 3+4j ...
xah lee
p0lyglut
Offline Send Email
Jan 9, 2005
8:22 am
3
#strings are enclosed in double quotes quotes. e.g. a="this and that" print a #multiple lines must have an escape backslash at the end: b="this\n\ and that" ...
xah lee
p0lyglut
Offline Send Email
Jan 10, 2005
8:36 am
4
# strings can be joined by +. print "this" + " that" # string can be multiplied print "this" *5 # substring extraction is done by appending a bracket # with...
xah lee
p0lyglut
Offline Send Email
Jan 11, 2005
7:08 am
5
# in Python, list can be done this way: a = [0, 1, 2, 'more',4,5,6] print a # list can be joined with plus sign b = a + [4,5,6] print b # list can be extracted...
xah lee
p0lyglut
Offline Send Email
Jan 12, 2005
6:51 am
6
# here's a while statement in python. a,b = 0,1 while b < 20: print b a,b = b,a+b ... # here's the same code in perl ($a,$b)=(0,1); while ($b<20) { print $b,...
xah lee
p0lyglut
Offline Send Email
Jan 13, 2005
10:16 am
7
while programing in Python, one can lookup syntax or info for keywords or modules within Python. In the command line, type python to get into the python...
xah lee
p0lyglut
Offline Send Email
Jan 14, 2005
9:31 am
8
# here's an example of if statement in python. x=-1 if x<0: print 'neg' elif x==0: print 'zero' elif x==1: print 'one' else: print 'other' # the elif can be...
xah lee
p0lyglut
Offline Send Email
Jan 15, 2005
3:04 am
9
# this is an example of for statement # the % symbol calculates the remainder # of division. # the range(m,n) function # gives a list from m to n-1. a =...
xah lee
p0lyglut
Offline Send Email
Jan 15, 2005
9:31 am
10
... And so, in an effort to stop Xah Lee from cross-posting things that have nothing to do with lisp, here is how it's done in Common Lisp. Please post...
drew_crampsie
Offline Send Email
Jan 16, 2005
9:15 am
11
... [snip] ... A real Perl programmer would write that as @a = (1 .. 50); for (@a) { unless ($_ % 2) { print "$_ even\n"; } } Or, even better, @a = (1 .. 50); ...
Dave Cross
daveorguk
Offline Send Email
Jan 16, 2005
9:19 am
12
... [ snip ] ... Specifically the Math::Complex package which comes as a standard part of every Perl installation. Dave......
Dave Cross
daveorguk
Offline Send Email
Jan 16, 2005
9:24 am
13
... [ snip ] ... Nope. The @ sign tells Perl that the variable is an array. Arrays and lists are two different things in Perl. ... Well, Perl can print lists...
Dave Cross
daveorguk
Offline Send Email
Jan 16, 2005
9:39 am
14
... [ snip ] ... Perl syntax is described in "perldoc perlsyn" ... But as qq is an operator, not a function the best documentation for it is in "perldoc...
Dave Cross
daveorguk
Offline Send Email
Jan 16, 2005
9:44 am
15
fscking yahoo ate all my tabs, so the source is not quite right. how do python programmers avoid this? for a non-munged version, see the *hyper-cliki* page : ...
drew_crampsie
Offline Send Email
Jan 16, 2005
9:54 am
16
# the following is a example of defining # a function in Python. def fib(n): """This prints n terms of a sequence where each term is the sum of previous two, ...
xah lee
p0lyglut
Offline Send Email
Jan 16, 2005
2:33 pm
17
# -*- coding: utf-8 -*- # Python # the “filter” function can be used to # reduce a list such that unwanted # elements are removed. # example: def even(n):...
xah lee
p0lyglut
Offline Send Email
Jan 17, 2005
2:43 am
18
some errors in past postings: * 20050117: Apply should've been Select. (the Mathematica function akin to Python's “filter”) * 20050116: in the perl...
xah lee
p0lyglut
Offline Send Email
Jan 18, 2005
5:42 am
19
# -*- coding: utf-8 -*- # in Python, there's a special type of # data structure called keyed list. it # is a unordered list of pairs, each # consists of a key...
xah lee
p0lyglut
Offline Send Email
Jan 18, 2005
5:42 am
20
# python provides some convenient # construct to loop thru lists or # dictionaries # the following construct loops thru a # dictionary each time assiging both ...
xah lee
p0lyglut
Offline Send Email
Jan 18, 2005
8:21 am
21
# -*- coding: utf-8 -*- # Python # one can write functions, # save it in a file # and later on load the file # and use these functions. # For example, save the...
xah lee
p0lyglut
Offline Send Email
Jan 19, 2005
5:04 am
22
# -*- coding: utf-8 -*- # Python # once a module is loaded # import mymodule # one can find all the names it # export with dir() import sys print dir(sys) #...
xah lee
p0lyglut
Offline Send Email
Jan 20, 2005
7:41 am
23
# -*- coding: utf-8 -*- # Python # there are several ways to format # output strings. repr() is for turning a # data into a string form that can be # read back...
xah lee
p0lyglut
Offline Send Email
Jan 21, 2005
11:42 am
24
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second...
xah lee
p0lyglut
Offline Send Email
Jan 22, 2005
11:51 am
25
# -*- coding: utf-8 -*- # Python # in Python, one can define a boxed set # of data and functions, which are # traditionally known as "class". # in the...
xah lee
p0lyglut
Offline Send Email
Jan 24, 2005
2:52 pm
26
# -*- coding: utf-8 -*- # Python # some venture into standard modules import os # print all names exported by the module print dir(os) # print the module's...
xah lee
p0lyglut
Offline Send Email
Jan 25, 2005
4:34 pm
27
# -*- coding: utf-8 -*- # Python import sys nn = len(sys.argv) if not nn==5: print "error: %s search_text replace_text in_file out_file" % sys.argv[0] else: ...
xah lee
p0lyglut
Offline Send Email
Jan 26, 2005
8:25 pm
28
# -*- coding: utf-8 -*- # Python # suppose you want to walk into a directory, say, to apply a string replacement to all html files. The os.path.walk() rises...
xah lee
p0lyglut
Offline Send Email
Jan 27, 2005
7:30 pm
29
hi all, i've created a webpage to archive all these daily tips. The url is http://xahlee.org/perl-python/python.html past emails will be added in in the next...
xah lee
p0lyglut
Offline Send Email
Jan 28, 2005
9:22 am
30
in computer languages, often a function definition looks like this: subroutine f (x1, x2, ...) { variables ... do this or that } in advanced languages such as...
Xah Lee
p0lyglut
Offline Send Email
Jan 28, 2005
11:02 pm
Messages 1 - 30 of 127   Oldest  |  < Older  |  Newer >  |  Newest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help