Re: [Tutor] python and sqlite

2010-01-31 Thread Samuel de Champlain
Thank you. I will read it next.
Here is another short one that I found:
http://www.wdvl.com/Authoring/python/SQLite/Watts07162009.html
If anyone knows of other tutorials on python and sqlite, please tell me of
them.


On Sun, Jan 31, 2010 at 11:08 PM, Victoria Wood <
cabbagetreecust...@gmail.com> wrote:

> Hi, I am very new to Python myself and decided to use sqlite so I could
> learn about gui programming. Although it has a lot of adverts on and is
> short I found this tutorial very useful
>
> http://www.devshed.com/c/a/Python/Using-SQLite-in-Python/
>
> I hope I have replied to this correctly.
>
> Victoria
>
> On Sun, Jan 31, 2010 at 11:03 AM, Samuel de Champlain <
> samueldechampl...@gmail.com> wrote:
>
> > My project is relatively light and postgresql or mysql might be overkill.
> > Does python work well with sqlite?
> > If so, can you point me towards the proper libraries and
> manuals/tutorials?
> > Thanks.
> >
> > __
> _
> > Tutor maillist  -  Tutor@python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Deterimining the maximum length of a field in csv file

2010-01-31 Thread Johann Spies
I would appreciate some help on this:

I want a script that can

1. determine the fieldnames from a csv file from the first line
2. determine the maximum length of data for each field in that file.

So far I could not figure out how to do 1 and my effort for the second
one is not working as expected.  Here is my present code:

reader = 
csv.DictReader(open("/media/usb0/kbase/web2py/db_scopus_rou.csv"),delimiter
= ',')
csv.field_size_limit(100)
reader.fieldnames  = ["scopus_rou.id","scopus_rou.Authors","scopus_rou.Title",
 "scopus_rou.Year","scopus_rou.Source_title","scopus_rou.Volume",
 "scopus_rou.Issue","scopus_rou.Art_No","scopus_rou.Page_start",
 "scopus_rou.Page_end","scopus_rou.Page_count","scopus_rou.Cited_by",
 "scopus_rou.Link","scopus_rou.Affiliations",
 "scopus_rou.Authors_with_affiliations","scopus_rou.Abstract",
 "scopus_rou.Author_Keywords","scopus_rou.Index_Keywords",
 "scopus_rou.Molecular_Sequence_Numbers","scopus_rou.Chemicals_CAS",
 "scopus_rou.Tradenames","scopus_rou.Manufacturers",
 "scopus_rou.Funding_Details","scopus_rou.Refs",
 "scopus_rou.Correspondence_Address","scopus_rou.Editors",
 "scopus_rou.Sponsors","scopus_rou.Publisher",
 "scopus_rou.Conference_name","scopus_rou.Conference_date",
 "scopus_rou.Conference_location","scopus_rou.Conference_code",
 "scopus_rou.ISSN","scopus_rou.ISBN","scopus_rou.CODEN",
 "scopus_rou.DOI","scopus_rou.Pubmed_ID","scopus_rou.Language",
 "scopus_rou.Abbreviated_Source_Title","scopus_rou.Document_Type",
 "scopus_rou.Source"]

maksimum = { "scopus_rou.id":0,"scopus_rou.Authors":0,"scopus_rou.Title":0,
 "scopus_rou.Year":0,"scopus_rou.Source_title":0,"scopus_rou.Volume":0,
 "scopus_rou.Issue":0,"scopus_rou.Art_No":0,"scopus_rou.Page_start":0,
 
"scopus_rou.Page_end":0,"scopus_rou.Page_count":0,"scopus_rou.Cited_by":0,
 "scopus_rou.Link":0,"scopus_rou.Affiliations":0,
 "scopus_rou.Authors_with_affiliations":0,"scopus_rou.Abstract":0,
 "scopus_rou.Author_Keywords":0,"scopus_rou.Index_Keywords":0,
 "scopus_rou.Molecular_Sequence_Numbers":0,"scopus_rou.Chemicals_CAS":0,
 "scopus_rou.Tradenames":0,"scopus_rou.Manufacturers":0,
 "scopus_rou.Funding_Details":0,"scopus_rou.Refs":0,
 "scopus_rou.Correspondence_Address":0,"scopus_rou.Editors":0,
 "scopus_rou.Sponsors":0,"scopus_rou.Publisher":0,
 "scopus_rou.Conference_name":0,"scopus_rou.Conference_date":0,
 "scopus_rou.Conference_location":0,"scopus_rou.Conference_code":0,
 "scopus_rou.ISSN":0,"scopus_rou.ISBN":0,"scopus_rou.CODEN":0,
 "scopus_rou.DOI":0,"scopus_rou.Pubmed_ID":0,"scopus_rou.Language":0,
 "scopus_rou.Abbreviated_Source_Title":0,"scopus_rou.Document_Type":0,
 "scopus_rou.Source":0}
ry = 0
try:
for row in reader:
ry = ry + 1
for k in  reader.fieldnames:
try:
lengte = len(row[k].strip())
except:
lengte = 0
if k in maksimum:
if lengte > maksimum[k]:
maksimum[k]= lengte
else:
maksimum[k] = lengte
print maksimum
except:
pass

for l in maksimum.keys:
print ("%s: %d\n" % (l, maksimum(l)))


Regards
Johann
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python and sqlite

2010-01-31 Thread Victoria Wood
Hi, I am very new to Python myself and decided to use sqlite so I could
learn about gui programming. Although it has a lot of adverts on and is
short I found this tutorial very useful

http://www.devshed.com/c/a/Python/Using-SQLite-in-Python/

I hope I have replied to this correctly.

Victoria

On Sun, Jan 31, 2010 at 11:03 AM, Samuel de Champlain <
samueldechampl...@gmail.com> wrote:

> My project is relatively light and postgresql or mysql might be overkill.
> Does python work well with sqlite?
> If so, can you point me towards the proper libraries and
manuals/tutorials?
> Thanks.
>
> __
_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] can any one help

2010-01-31 Thread Benno Lang
On Mon, Feb 1, 2010 at 6:27 AM, invincible patriot
 wrote:
> thanks for the reply
> i did one question
> i will tel u my progress in another question n then u tel me that what next
> must be done



> thatz the question
> i think that first i woulf take a string 'foobar'
> convert it into a list
> take itz length
> n then do indexing
> and then multiply using for loop
>
> herez my code



> thatz where i am
> now i wana do the indexing of each character so that i use for loop n
> multply each character with 2
>
>
> waiting for ur reply

Hi there,

I think everyone on the list would appreciate it if you wrote in
English, not gibberish.

Regards,
benno.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] query

2010-01-31 Thread R. Alan Monroe

> i just don wana index all the characters rather i wana double it too like 
>  ['d','a','v','i','d']
> would b 
>  ['d','dd','a','aa','v','vv','i','ii','d','dd']
> and then i wana replace all non 'd' characters with '.' a dot

> i know how replace a specific character, but i don know how to
> replace all characters other than a specific character

Hint 1: a FOR loop will help you count your way through lists one
at a time. Let the computer do the counting for you.

Hint 2: learn about IF statements to replace characters IF they're not
a d, for example.

Alan

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] parse text file

2010-01-31 Thread Norman Khine
Hello,
I am still unable to get this to work correctly!

In [1]: file=open('producers_google_map_code.txt', 'r')

In [2]: data =  repr( file.read().decode('utf-8') )

In [3]: from BeautifulSoup import BeautifulStoneSoup

In [4]: soup = BeautifulStoneSoup(data)

In [6]: soup

http://paste.lisp.org/display/94195

In [7]: import re

In [8]: p = re.compile(r"""GLatLng\((\d+\.\d*)\, \n (\d+\.\d*)\)""")

In [9]: r = p.findall(data)

In [10]: r
Out[10]: []

see http://paste.lisp.org/+20BO/1

i can't seem to get the regex correct

(r"""GLatLng\((\d+\.\d*)\, \n (\d+\.\d*)\)""")

the problem is that, each for example is:

GLatLng(27.729912,\\n  85.31559)
GLatLng(-18.889851,\\n  -66.770897)

i have a big whitespace, plus the group can have a negative value, so
if i do this:

In [31]: p = re.compile(r"""GLatLng\((\d+\.\d*)\,\\n
   (\d+\.\d*)\)""")

In [32]: r = p.findall(data)

In [33]: r
Out[33]:
[('27.729912', '85.31559'),
 ('9.696333', '122.985992'),
 ('17.964625', '102.60040'),
 ('21.046439', '105.853043'),

but this does not take into account of data which has negative values,
also i am unsure how to pull it all together. i.e. to return a CSV
file such as:

"ACP", "acp.html", "9.696333", "122.985992"
"ALTER TRADE CORPORATION", "alter-trade-corporation.html",
"-18.889851", "-66.770897"

Thanks


On Sat, Jan 23, 2010 at 12:50 AM, spir  wrote:
> On Sat, 23 Jan 2010 00:22:41 +0100
> Norman Khine  wrote:
>
>> Hi
>>
>> On Fri, Jan 22, 2010 at 7:44 PM, spir  wrote:
>> > On Fri, 22 Jan 2010 14:11:42 +0100
>> > Norman Khine  wrote:
>> >
>> >> but my problem comes when i try to list the GLatLng:
>> >>
>> >> GLatLng(9.696333, 122.985992);
>> >>
>> >> >>> StartingWithGLatLng = soup.findAll(re.compile('GLatLng'))
>> >> >>> StartingWithGLatLng
>> >> []
>> >
>> > Don't about soup's findall. But the regex pattern string should rather be 
>> > something like (untested):
>> >   r"""GLatLng\(\(d+\.\d*)\, (d+\.\d*)\) """
>> > capturing both integers.
>> >
>> > Denis
>> >
>> > PS: finally tested:
>> >
>> > import re
>> > s = "GLatLng(9.696333, 122.985992)"
>> > p = re.compile(r"""GLatLng\((\d+\.\d*)\, (\d+\.\d*)\)""")
>> > r = p.match(s)
>> > print r.group()         # --> GLatLng(9.696333, 122.985992)
>> > print r.groups()        # --> ('9.696333', '122.985992')
>> >
>> > s = "xGLatLng(1.1, 11.22)xxxGLatLng(111.111, .)x"
>> > r = p.findall(s)
>> > print r                         # --> [('1.1', '11.22'), ('111.111', 
>> > '.')]
>>
>> Thanks for the help, but I can't seem to get the RegEx to work correctly.
>>
>> Here is my input and output:
>>
>> http://paste.lisp.org/+20BO/1
>
> See my previous examples...
> If you use match:
>
> In [6]: r = p.match(data)
>
> Then the result is a regex match object (unlike when using findall). To get 
> the string(s) matched; you need to use the group() and/or groups() methods.
>
 import re
 p = re.compile('x')
 print p.match("xabcx")
> <_sre.SRE_Match object at 0xb74de6e8>
 print p.findall("xabcx")
> ['x', 'x']
>
> Denis
> 
>
> la vita e estrany
>
> http://spir.wikidot.com/
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] can any one help

2010-01-31 Thread Luke Paireepinart
On Sun, Jan 31, 2010 at 3:27 PM, invincible patriot <
invincible_patr...@hotmail.com> wrote:

>  thanks for the reply
> i did one question
> i will tel u my progress in another question n then u tel me that what next
> must be done
>
> thanks
>
> Write a small Python program that generates the list of all pairs of
> characters c and
> its doubling 2 c, where c moves through all the letters of the string
> "foobar" and prints it out.
> The result will look like:
> [(’f’, ’ff’), (’o’, ’oo’), (’o’, ’oo’), (’b’, ’bb’), (’a’, ’aa’), (’r’,
> ’rr’)]
>
> thatz the question
> i think that first i woulf take a string 'foobar'
> convert it into a list
> take itz length
> n then do indexing
> and then multiply using for loop
>
> herez my code
>
> a='foobar'
> b=list(a)
> print b
>
> ['f','o','o','b','a','r']
>
> c=len(b)
> 6
>
>
> thatz where i am
> now i wana do the indexing of each character so that i use for loop n
> multply each character with 2
>
>
See now that you have provided us with what you've tried we can help you a
little more.
How do you think you should do the multiplication?  You mentioned a 'for
loop' but you didn't actually try using one in your code.

Also one hint, strings can be used directly in this situation.
as an example,
a = 'foobar'
len(a)
6

You don't actually have to convert it to a list before iterating over it.

-Luke
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] query

2010-01-31 Thread invincible patriot

i just don wana index all the characters rather i wana double it too like 
 ['d','a','v','i','d']
would b 
 ['d','dd','a','aa','v','vv','i','ii','d','dd']
and then i wana replace all non 'd' characters with '.' a dot

i know how replace a specific character, but i don know how to replace all 
characters other than a specific character


thanks



> Subject: Re: [Tutor] query
> From: grigor.ko...@gmail.com
> To: invincible_patr...@hotmail.com
> CC: anand.shash...@gmail.com; da...@pythontoo.com; tutor@python.org
> Date: Sun, 31 Jan 2010 23:49:58 +0200
> 
> В 21:21 + на 31.01.2010 (нд), invincible patriot написа:
> > Hi
> > can any one tel me how can i do indexing of individual characters in
> > python
> > like if i hav a word eg david
> > a='david'
> > b=list(a)
> > # this will give ['d','a','v','i','d']
> > not i want to print the index of each character
> > how can i do that
> > please tel me
> > 
> > thanks
> > 
> > 
> > 
> > __
> > Hotmail: Free, trusted and rich email service. Get it now.
> > ___
> > Tutor maillist  -  Tutor@python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
> List indexed by position
> ['d','a','v','i','d']
> 0,1,2,3,4,5
> Can index like this
> a[1]
> You can index and string too not need to be a list
> a[1]
> if you want find position of 'a' use this
> a.find('a')
> -- 
> Grigor Kolev 
> 
  
_
Hotmail: Free, trusted and rich email service.
http://clk.atdmt.com/GBL/go/196390708/direct/01/___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] query

2010-01-31 Thread Grigor Kolev
В 21:21 + на 31.01.2010 (нд), invincible patriot написа:
> Hi
> can any one tel me how can i do indexing of individual characters in
> python
> like if i hav a word eg david
> a='david'
> b=list(a)
> # this will give ['d','a','v','i','d']
> not i want to print the index of each character
> how can i do that
> please tel me
> 
> thanks
> 
> 
> 
> __
> Hotmail: Free, trusted and rich email service. Get it now.
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
List indexed by position
['d','a','v','i','d']
0,1,2,3,4,5
Can index like this
a[1]
You can index and string too not need to be a list
a[1]
if you want find position of 'a' use this
a.find('a')
-- 
Grigor Kolev 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] kudos to alan

2010-01-31 Thread Darren Short
+1

Agreed.  Why "do" python if you can't take the time to learn it.   One must
put in the work, or at least show what work has been done when not being
able to reach a solution just quite yet.


On Sun, Jan 31, 2010 at 12:49 PM, Shashwat Anand
wrote:

> +1
>
> On Mon, Feb 1, 2010 at 2:01 AM, David Abbott  wrote:
>
>> On Sun, 2010-01-31 at 11:58 -0800, David Hutto wrote:
>> >
>> >
>> > --- On Sun, 1/31/10, Woodwerks  wrote:
>> >
>> >
>> >
>> >
>> > I think the way you give hints and ideas about how to
>> > accomplish something in Python is excellent. I sometimes work
>> > through these problems just to build skills. I know it would
>> > be easy for you to provide a built solution, but this
>> > exercises the brain in a much better way. Kudos, Alan.
>> >
>> >
>> >
>> >
>> > I'll second the motion.
>> >
>> >
>>
>> + 3
>> --
>> David Abbott 
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] query

2010-01-31 Thread Sander Sweers
On 31 January 2010 22:21, invincible patriot
 wrote:
> can any one tel me how can i do indexing of individual characters in python
> like if i hav a word eg david
> a='david'
> b=list(a)
> # this will give ['d','a','v','i','d']
> not i want to print the index of each character
> how can i do that
> please tel me

Look at http://diveintopython.org/getting_to_know_python/lists.html.

Greets
Sander
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] can any one help

2010-01-31 Thread invincible patriot

thanks for the reply
i did one question
i will tel u my progress in another question n then u tel me that what next 
must be done

thanks
Write a small Python program that generates the list of all pairs of characters 
c and
its doubling 2  c, where c moves through all the letters of the string 
"foobar" and prints it out.
The result will look like:
[(’f’, ’ff’), (’o’, ’oo’), (’o’, ’oo’), (’b’, ’bb’), (’a’, ’aa’), (’r’, ’rr’)]

thatz the question
i think that first i woulf take a string 'foobar'
convert it into a list
take itz length
n then do indexing
and then multiply using for loop

herez my code

a='foobar'
b=list(a)
print b
['f','o','o','b','a','r']

c=len(b)
6


thatz where i am
now i wana do the indexing of each character so that i use for loop n multply 
each character with 2


waiting for ur reply


> Date: Sun, 31 Jan 2010 11:01:19 -0500
> From: amon...@columbus.rr.com
> To: tutor@python.org
> Subject: Re: [Tutor] can any one help
> 
> 
> > 1 1.1 Write a Python program with a loop that prints out a sequence
> > of numbers as follows:15 13 11...3 1 -1
> 
> Hint 1: Learn about FOR loops.
> 
> Hint 2: Learn about the RANGE command.
> 
> Hint 3: Show us some code you have written. Even if yours doesn't
> work, we can probably spot WHY it doesn't work.
> 
> Alan
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
  
_
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/196390707/direct/01/___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Future Appointments...

2010-01-31 Thread Ken G.

Sorry, I forgot to hit Reply All.


That is so cool!  My first look at 'pastebin.'  THANKS!

I already finished the code up several hours ago.  If I can figure out 
how to post it there.



Ken



Robert Berman wrote:

-Original Message-
From: tutor-bounces+bermanrl=cfl.rr@python.org
[mailto:tutor-bounces+bermanrl=cfl.rr@python.org] On Behalf Of Ken G.
Sent: Sunday, January 31, 2010 10:41 AM
To: tutor@python.org
Subject: [Tutor] Future Appointments...

Below is a program to determine when my next appointment is.  Line 
numbers are provided for reference only.


01  import time, datetime, sys
02  from datetime import date
03  today = date.today()
04  print
05  print "Today date is:", today
06  todaystr = str(today)
07  print
08  print "Corrected date format is:",
09  print todaystr[ 5: 7], todaystr[ 8:10], todaystr[ 0: 4]
10  print
11  future = raw_input("Next appointment is in how many days?  "),
12  print
13  difference1 = datetime.timedelta(days=1)
14  datestring = str(today + difference1)
15  print "Next appointment after that is:",datestring
16  print
17  print "Corrected date format for next appointment is:",
18  print datestring[ 5: 7], datestring[ 8:10], datestring[ 0: 4]
19  sys.exit()

In answering the question in line 11 as to when is my next appointment, 
I would answer "3" (for 2/3/2010) but how do I change "days=1" at end of 
line 13 to "days=3" so that datestring would read "2010-02-03" instead 
of "2010-02-01" as presented above?


TIA,

Ken
*

Hi Ken,

I slightly altered your program. I think this is what you asked for. It will
work for n number of days; for example, 1, 10, 45, 118, 412 work nicely.

See code here: http://pastebin.com/m6e78d3ce

Robert


  

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] query

2010-01-31 Thread invincible patriot

Hi
can any one tel me how can i do indexing of individual characters in python
like if i hav a word eg david
a='david'
b=list(a)
# this will give ['d','a','v','i','d']
not i want to print the index of each character
how can i do that
please tel me

thanks

  
_
Hotmail: Free, trusted and rich email service.
http://clk.atdmt.com/GBL/go/196390708/direct/01/___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] kudos to alan

2010-01-31 Thread Shashwat Anand
+1

On Mon, Feb 1, 2010 at 2:01 AM, David Abbott  wrote:

> On Sun, 2010-01-31 at 11:58 -0800, David Hutto wrote:
> >
> >
> > --- On Sun, 1/31/10, Woodwerks  wrote:
> >
> >
> >
> >
> > I think the way you give hints and ideas about how to
> > accomplish something in Python is excellent. I sometimes work
> > through these problems just to build skills. I know it would
> > be easy for you to provide a built solution, but this
> > exercises the brain in a much better way. Kudos, Alan.
> >
> >
> >
> >
> > I'll second the motion.
> >
> >
>
> + 3
> --
> David Abbott 
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] kudos to alan

2010-01-31 Thread David Abbott
On Sun, 2010-01-31 at 11:58 -0800, David Hutto wrote:
> 
> 
> --- On Sun, 1/31/10, Woodwerks  wrote:
> 
> 
> 
> 
> I think the way you give hints and ideas about how to
> accomplish something in Python is excellent. I sometimes work
> through these problems just to build skills. I know it would
> be easy for you to provide a built solution, but this
> exercises the brain in a much better way. Kudos, Alan.
> 
> 
> 
> 
> I'll second the motion.
> 
> 

+ 3
-- 
David Abbott 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] kudos to alan

2010-01-31 Thread David Hutto


--- On Sun, 1/31/10, Woodwerks  wrote:

From: Woodwerks 
Subject: [Tutor] kudos to alan
To: tutor@python.org
Date: Sunday, January 31, 2010, 2:33 PM

Message: 4
Date: Sun, 31 Jan 2010 11:01:19 -0500
From: "R. Alan Monroe"
To:tutor@python.org
Subject: Re: [Tutor] can any one help
Message-ID:<4681047264.20100131110...@columbus.rr.com>
Content-Type: text/plain; charset=us-ascii

I think the way you give hints and ideas about how to accomplish something in 
Python is excellent. I sometimes work through these problems just to build 
skills. I know it would be easy for you to provide a built solution, but this 
exercises the brain in a much better way. Kudos, Alan.

> >  1 1.1 Write a Python program with a loop that prints out a sequence
> >  of numbers as follows:15 13 11...3 1 -1
>    
Hint 1: Learn about FOR loops.

Hint 2: Learn about the RANGE command.

Hint 3: Show us some code you have written. Even if yours doesn't
work, we can probably spot WHY it doesn't work.

Alan

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor






I'll second the motion.




  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Future Appointments...

2010-01-31 Thread Robert Berman


-Original Message-
From: tutor-bounces+bermanrl=cfl.rr@python.org
[mailto:tutor-bounces+bermanrl=cfl.rr@python.org] On Behalf Of Ken G.
Sent: Sunday, January 31, 2010 10:41 AM
To: tutor@python.org
Subject: [Tutor] Future Appointments...

Below is a program to determine when my next appointment is.  Line 
numbers are provided for reference only.

01  import time, datetime, sys
02  from datetime import date
03  today = date.today()
04  print
05  print "Today date is:", today
06  todaystr = str(today)
07  print
08  print "Corrected date format is:",
09  print todaystr[ 5: 7], todaystr[ 8:10], todaystr[ 0: 4]
10  print
11  future = raw_input("Next appointment is in how many days?  "),
12  print
13  difference1 = datetime.timedelta(days=1)
14  datestring = str(today + difference1)
15  print "Next appointment after that is:",datestring
16  print
17  print "Corrected date format for next appointment is:",
18  print datestring[ 5: 7], datestring[ 8:10], datestring[ 0: 4]
19  sys.exit()

In answering the question in line 11 as to when is my next appointment, 
I would answer "3" (for 2/3/2010) but how do I change "days=1" at end of 
line 13 to "days=3" so that datestring would read "2010-02-03" instead 
of "2010-02-01" as presented above?

TIA,

Ken
*

Hi Ken,

I slightly altered your program. I think this is what you asked for. It will
work for n number of days; for example, 1, 10, 45, 118, 412 work nicely.

See code here: http://pastebin.com/m6e78d3ce

Robert

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] kudos to alan

2010-01-31 Thread Woodwerks

Message: 4
Date: Sun, 31 Jan 2010 11:01:19 -0500
From: "R. Alan Monroe"
To:tutor@python.org
Subject: Re: [Tutor] can any one help
Message-ID:<4681047264.20100131110...@columbus.rr.com>
Content-Type: text/plain; charset=us-ascii

I think the way you give hints and ideas about how to accomplish something in 
Python is excellent. I sometimes work through these problems just to build 
skills. I know it would be easy for you to provide a built solution, but this 
exercises the brain in a much better way. Kudos, Alan.


>  1 1.1 Write a Python program with a loop that prints out a sequence
>  of numbers as follows:15 13 11...3 1 -1
   

Hint 1: Learn about FOR loops.

Hint 2: Learn about the RANGE command.

Hint 3: Show us some code you have written. Even if yours doesn't
work, we can probably spot WHY it doesn't work.

Alan

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python and sqlite

2010-01-31 Thread Chris Fuller

Since v2.5, SQLite is included in the Standard Library.  You can get docs at 
the Python website, or in the handy chm that comes with the Windows 
distribution.

Cheers

On Sunday 31 January 2010, Samuel de Champlain wrote:
> My project is relatively light and postgresql or mysql might be overkill.
> Does python work well with sqlite?
> If so, can you point me towards the proper libraries and manuals/tutorials?
> Thanks.
> 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python and sqlite

2010-01-31 Thread Luke Paireepinart
Yes, it works fine with sqlite.  I've seen very large projects use it just
fine.
I'd recommend googling "pysqlite" or something similar.
-Luke

On Sun, Jan 31, 2010 at 11:03 AM, Samuel de Champlain <
samueldechampl...@gmail.com> wrote:

> My project is relatively light and postgresql or mysql might be overkill.
> Does python work well with sqlite?
> If so, can you point me towards the proper libraries and manuals/tutorials?
> Thanks.
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] please help me

2010-01-31 Thread Luke Paireepinart
Please reply on-list unless you really need to speak to me off-list.
Use "reply-all" to reply to everyone.

Tutor doesn't work in that you get one of us as a tutor and we help you with
every problem you have.  For this mailing list you e-mail us a specific
problem and everyone collaborates to guide you through it.  When we say
"specific problem" we mean "you have coded a solution that looks to you like
it would work but it doesn't and you're stuck" and then we'll help you
figure out why you're stuck and what you need to do to fix the program.

(P.S. Sorry for the top-post, I'm not sure how to reply in-line to a
forwarded message.)


-- Forwarded message --
From: invincible patriot 
Date: Sun, Jan 31, 2010 at 4:05 AM
Subject: RE: [Tutor] please help me
To: rabidpoob...@gmail.com


 m sorry but i am not asking u to solve these for me rather i send all the
questions to u just to let u know what i want to do n now i m looking
froward for ur guidance so that i can write programme for thhem
i think itz fair enough to ask what should i do, but i am not asking u to
solve them for me
m just looking forward for some help


--
From: rabidpoob...@gmail.com
Date: Sat, 30 Jan 2010 19:39:05 -0600
Subject: Re: [Tutor] please help me
To: invincible_patr...@hotmail.com
CC: tutor@python.org


[snip homework]



please help me


This is a tutor mailing list.  Tutor means we will help you learn, not that
we will write your homework assignments for you for free.  That is the
opposite of learning.

Try all of the programs.  Give us what you have tried and what didn't work,
why you thought it would work, why you think it didn't work, and anything
else helpful (eg. if you get an error message include the whole traceback,
don't paraphrase it.)

In other words, if you don't have code that you've tried and a specific
problem you're having, you're not going to get a reply.  We're busy people,
make it easy for us to help you.

-Luke


--
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. Sign up
now.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] python and sqlite

2010-01-31 Thread Samuel de Champlain
My project is relatively light and postgresql or mysql might be overkill.
Does python work well with sqlite?
If so, can you point me towards the proper libraries and manuals/tutorials?
Thanks.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Complied Python program...

2010-01-31 Thread Alan Gauld


"Ken G."  wrote

In using Geany, I have the ability to complied a Python program.  For 
example, I can complied "program.py" to program.pyc."


You compile (note spelling) a python script everytime you import it
(if it has not already been compiled).
If you compile a new(or changed) script Python first compiles the
source text into an intermediate version called byte code (sometimes
called p-code) that the interpreter can understand and execute. It
saves the byte-code as a .pyc file so that in future it can import
the compiled version directly (if there is no newer .py file).

This byte-code is similar to what Java produces when you comile jave
into a class file. The Jave runtime engine is basically an interpreter
for Java byte-code. .Net code follows a similar approach too.

What is the purpose of a complied Python program?  Can it be transported 
to another computer without Python installed as run as it is?


No, it needs Python to run it but it can be transported without
the .py file existing - which gives a minimal amount of code
hiding and a marginal startup advantage the first time you run it.
Its not usually worth it IMHO.

You can see the p-code if you use the dis module. The docs give this 
example:



def myfunc(alist):

... return len(alist)
...>>> dis.dis(myfunc)
 2   0 LOAD_GLOBAL  0 (len)
 3 LOAD_FAST0 (alist)
 6 CALL_FUNCTION1
 9 RETURN_VALUE
The bytecode : 0,0,3,0,6,1,9 is more compact but much more primitive than 
the original source text. It is similasr in character to a machine code 
program but is machine independant.Thus it is said to run on a virtual 
machine - the Python interpreter.HTH,-- Alan GauldAuthor of the Learn to 
Program web sitehttp://www.alan-g.me.uk/ 



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Fw: Future of Python Programmers

2010-01-31 Thread ALAN GAULD
Forwarding since I assume this was meant to go 
to either the list or the OP, rather than 
just me...

 Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/



>
>- Forwarded Message 
>From: Samuel de Champlain 
>To: Alan Gauld 
>Sent: Sunday, 31 January, 2010 14:40:36
>Subject: Re: [Tutor] Future of Python Programmers
>
>In order to get faster programs, you have to become more machine specific. If 
>you want your program to work on several machines, you must include more code 
>for each possible machine architecture. Python and java try to realise the old 
>dream of coding once and running everywhere, therefore they have to be slower 
>in execution, but with the speed of modern machines, this becomes less 
>important. 
>>However, they are fantastic rad (rapid application development) languages. 
>>Time to market and therefore cost is greatly reduced and that is the main 
>>reason they are widely used. Try debugging c and you will learn to appreciate 
>>garbage collectors and the lack of pointer headaches in python.
>>But that is just one person's opinion.
>
>
>On Sun, Jan 31, 2010 at 4:26 AM, Alan Gauld  wrote:
>
>
"nikunj badjatya"  wrote
>>
>>
>I have one important question to ask to all of you,
>>I am a fresher, recently completed my graduation, had started working on
>>python 2 months back..!! and I just fell in love with the language.
>>The only concern is there arent enough companies which work on Python.
>>>
How many companies do you need?
One is enough if you fork for that one...
>>
>>
>Is there any chance where the development of Python will make it as fast as
>>C++ or JAVA, (or it is at its optimum level? ) .
>>>
No, just as there is no chance that Java will ever be as fast
as C++ or C++ as fast as C or C as fast as assembler.
You can construct test cases where they approach each other
but raw speed is related to how  close you can get to the machine.
The trade off is that raw speed requires guru level skill and a lot of
development time. So if you measure speed in terms of productivity
Python is already faster than Java!
>>
But your concerms are misplaced.
All programming languages (except perhaps COBOL and FORTRAN)
come and go. When I left university (mid 1980's) everyone was using
Pascal and C. ADA and Prolog were the forecast kings of the block
and a few people were playing with Smalltalk.Then Windows came out
and C++ suddenly took over. Then it was Java.Then scripting languages
became poular. I don;t know what we will be using in 20 years time but
it probavbly won't be Java or C++ or even Python.Get used to it, as a
professional you will learn and use many languages (I know over 20 that
I've used in real projects, and probavbly another dozen that I studied
just for the knowledge they gave). Languages are just not that important.
>>
Stop fiocussing on languages, start to focus on the deeper
fundamentals of programming. Design, architecture, state, data
structures, logic coupling, cohesion, concurrency etc
These things do not change.
>>
-- 
Alan Gauld
Author of the Learn to Program web site
>>http://www.alan-g.me.uk/
>>
>>
>>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
>>http://mail.python.org/mailman/listinfo/tutor
>>
>___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Complied Python program...

2010-01-31 Thread Wayne Werner
On Sun, Jan 31, 2010 at 9:46 AM, Ken G.  wrote:

> In using Geany, I have the ability to complied a Python program.  For
> example, I can complied "program.py" to program.pyc."
>
> What is the purpose of a complied Python program?  Can it be transported to
> another computer without Python installed as run as it is?  For example, use
> "run program.pyc" in Windows?  Currently, I am using Ubuntu 9.04, a Linux
> OS.
>

As far as I know - it speeds up loading time slightly, and no.

When you say "import foo" it first looks for the .pyc file in the local
directory, then the path. It will also look for the .py file if it can't
find a .pyc.

http://www.python.org/doc/1.5.1p1/tut/node43.html

HTH,
Wayne
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Future Appointments...

2010-01-31 Thread Sander Sweers
On 31 January 2010 16:40, Ken G.  wrote:
> Below is a program to determine when my next appointment is.  Line numbers
> are provided for reference only.
>
> 01  import time, datetime, sys
> 02  from datetime import date
> 03  today = date.today()
> 04  print
> 05  print "Today date is:", today
> 06  todaystr = str(today)

You should use today.strftime(), see [1] for the format.

> 07  print
> 08  print "Corrected date format is:",
> 09  print todaystr[ 5: 7], todaystr[ 8:10], todaystr[ 0: 4]

The above then would be. today.strftime('%Y-%m-%d').

> 10  print
> 11  future = raw_input("Next appointment is in how many days?  "),

This will give a string which will need to be converted to a int. You
can do this with int(future). For example d = int(future).

But this might fail if future is a string like b, $ or other non
number string. You can catch the error, see [2] how to do this.

> 12  print
> 13  difference1 = datetime.timedelta(days=1)

When you converted future to an int variable d replace days=1 with days=d.

> 14  datestring = str(today + difference1)

You can use strftime() above.

> 15  print "Next appointment after that is:",datestring
> 16  print
> 17  print "Corrected date format for next appointment is:",
> 18  print datestring[ 5: 7], datestring[ 8:10], datestring[ 0: 4]

Again, strftime() can be used.

> 19  sys.exit()
>
> In answering the question in line 11 as to when is my next appointment, I
> would answer "3" (for 2/3/2010) but how do I change "days=1" at end of line
> 13 to "days=3" so that datestring would read "2010-02-03" instead of
> "2010-02-01" as presented above?

See comments inline also. You will need to convert your raw_input
result future to a number with "int()" and store it in a new variable
wich can be used in datetime.timedelta().

Greets
Sander

[1] http://docs.python.org/library/time.html#time.strftime
[2] http://docs.python.org/tutorial/errors.html
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] can any one help

2010-01-31 Thread Robert Berman
Grigor Kolev 

From: tutor-bounces+bermanrl=cfl.rr@python.org
[mailto:tutor-bounces+bermanrl=cfl.rr@python.org] On Behalf Of
invincible patriot
Sent: Sunday, January 31, 2010 5:03 AM
To: rabidpoob...@gmail.com; grigor.ko...@gmail.com
Cc: tutor@python.org
Subject: Re: [Tutor] can any one help

please check the questions below.

1
 1.1 Write a Python program with a loop that prints out a sequence of
numbers as follows:
15
13
11
...
3
1
-1


1.2 Write a small Python program that generates the list of all pairs of
characters c and
its doubling 2  c, where c moves through all the letters of the string
"foobar" and prints it out.
The result will look like:
[(’f’, ’ff’), (’o’, ’oo’), (’o’, ’oo’), (’b’, ’bb’), (’a’, ’aa’), (’r’,
’rr’)]
Hint: use list comprehensions.
.


What possible reason would you have for expecting anyone n this group to do
your school work for you?

If you really want help, show us the status of your current scripts and
quote us the errors you are receiving.

Good luck,

Robert

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] can any one help

2010-01-31 Thread R. Alan Monroe

> 1 1.1 Write a Python program with a loop that prints out a sequence
> of numbers as follows:15 13 11...3 1 -1

Hint 1: Learn about FOR loops.

Hint 2: Learn about the RANGE command.

Hint 3: Show us some code you have written. Even if yours doesn't
work, we can probably spot WHY it doesn't work.

Alan

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Complied Python program...

2010-01-31 Thread Ken G.
In using Geany, I have the ability to complied a Python program.  For 
example, I can complied "program.py" to program.pyc."


What is the purpose of a complied Python program?  Can it be transported 
to another computer without Python installed as run as it is?  For 
example, use "run program.pyc" in Windows?  Currently, I am using Ubuntu 
9.04, a Linux OS.


TIA,

Ken
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Future Appointments...

2010-01-31 Thread Ken G.
Below is a program to determine when my next appointment is.  Line 
numbers are provided for reference only.


01  import time, datetime, sys
02  from datetime import date
03  today = date.today()
04  print
05  print "Today date is:", today
06  todaystr = str(today)
07  print
08  print "Corrected date format is:",
09  print todaystr[ 5: 7], todaystr[ 8:10], todaystr[ 0: 4]
10  print
11  future = raw_input("Next appointment is in how many days?  "),
12  print
13  difference1 = datetime.timedelta(days=1)
14  datestring = str(today + difference1)
15  print "Next appointment after that is:",datestring
16  print
17  print "Corrected date format for next appointment is:",
18  print datestring[ 5: 7], datestring[ 8:10], datestring[ 0: 4]
19  sys.exit()

In answering the question in line 11 as to when is my next appointment, 
I would answer "3" (for 2/3/2010) but how do I change "days=1" at end of 
line 13 to "days=3" so that datestring would read "2010-02-03" instead 
of "2010-02-01" as presented above?


TIA,

Ken
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Problem creating a search

2010-01-31 Thread spir
On Sat, 30 Jan 2010 19:45:04 -0600
Luke Paireepinart  wrote:

> The key here is the "for line in infile" will not keep the whole file in
> memory 

... provided the file is structured in lines.
(Also, the searched term should not be nore hold a newline).

Denis


la vita e estrany

http://spir.wikidot.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] can any one help

2010-01-31 Thread invincible patriot

please check the questions below.
1 1.1 Write a Python program with a loop that prints out a sequence of numbers 
as follows:151311...31-1

1.2 Write a small Python program that generates the list of all pairs of 
characters c andits doubling 2  c, where c moves through all the letters of 
the string "foobar" and prints it out.The result will look like:[(’f’, ’ff’), 
(’o’, ’oo’), (’o’, ’oo’), (’b’, ’bb’), (’a’, ’aa’), (’r’, ’rr’)]Hint: use list 
comprehensions.
1.3 Write a small Python program that
1. prints out the length of the 
string’taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu’
2. prints out how many different characters this string contains
3. replaces all the non-’t’ characters in above string with dots ’.’. So, if 
the word were’tattoo’, it would print ’t.tt..’.Hints:
(a) use a function to t-ify the string
(b) there are various ways to construct the string, either using the join 
method or by runninga loop accumulating substrings.
(c) check also out what happens if you apply the conversion list(s) to a string 
s.
2 2.1 Write a function count char(s, c) that takes a string s, and a character 
c and returnshow often the character c appears in the string.For example 
count_char("tattoo", "t") should return 3.

2.2 Write a Python function char_freqency(s)that returns a dictionary which, 
for eachcharacter of s as a key, stores as value how often this character 
appears.For example, char_frequency("tattoo") could return {’a’: 1, ’t’: 3, 
’o’: 2} (the order ofkey:value pairs does not matter here).
Hint: Consider using the function count_char defined in 2.1.
2.3 Write a program that translates a given string (of arbitrary length) of DNA 
bases intothe RNA strand that it will produce. For this, research which DNA 
bases correspond to RNA basesand create a translation table (not an if...else 
clause!) in the Python program. [4 marks]


3 
3.1 consider the following list of base 
sequences:ACGTACCTTACTTACCATATCGTACCTCTTACTCATThe task consists of writing a 
Python program that performs a simple alignment algorithm onthese two strings 
and prints out this alignment in a suitable readable form. Give a brief 
commentexplaining the output format.Hints:1. Matching means the following: for 
a given sequence to be matched, your program should denotewhich bases 
correspond to bases in the reference sequence and which do not; in addition, 
markgaps where the reference sequence contains bases which are not present in 
the sample sequence.For a given sample sequence, your matching algorithm will 
attempt to match as many basesas possible to those of the reference sequence.2. 
This is a difficult assignment. Do not attempt it before you have solved the 
others.3. For this purpose, you are allowed to research and implement publicly 
documented versions ofthe Needleman-Wunsch algorithm or similar algorithms 
(however, make sure that you refer-ence them properly!). Also make sure that 
your program prints out the matches/mismatchesbetween the sequences. You should 
demonstrate at least two different alignments by usingdifferent gap 
penalties.Instead of following this hint, you can develop an alternative 
solution to the matching problem,e.g. based on the Levenshtein distance.


please help me

From: rabidpoob...@gmail.com
Date: Sat, 30 Jan 2010 19:36:30 -0600
Subject: Re: [Tutor] can any one help
To: grigor.ko...@gmail.com
CC: invincible_patr...@hotmail.com; tutor@python.org



On Sat, Jan 30, 2010 at 5:40 PM, Grigor Kolev  wrote:


Excuse me but I have question too.

Why when i write this function in python shell not work says

SyntaxError: invalid syntax

but when I use IDLE make endless loop
Your tabbing is probably messed up or something.

You guys both need to be a lot more clear with your questions.
If it doesn't seem like you put in the effort for a proper post then you're 
unlikely to get a proper reply.



-Luke
 

Sorry I also teach Python.

> def fibn(n):

> a,b=15,2

> while a>n:

> print a, # it is same like print a, a, b = a, a+b

> You can not print this. SyntaxError: invalid syntax

> a,b=a,a+b

> fibn(-1)

--

Grigor Kolev 



___

Tutor maillist  -  Tutor@python.org

To unsubscribe or change subscription options:

http://mail.python.org/mailman/listinfo/tutor


  
_
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/196390709/direct/01/___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Future of Python Programmers

2010-01-31 Thread Alan Gauld


"nikunj badjatya"  wrote


I have one important question to ask to all of you,
I am a fresher, recently completed my graduation, had started working on
python 2 months back..!! and I just fell in love with the language.
The only concern is there arent enough companies which work on Python.


How many companies do you need?
One is enough if you fork for that one...

Is there any chance where the development of Python will make it as fast 
as

C++ or JAVA, (or it is at its optimum level? ) .


No, just as there is no chance that Java will ever be as fast
as C++ or C++ as fast as C or C as fast as assembler.
You can construct test cases where they approach each other
but raw speed is related to how  close you can get to the machine.
The trade off is that raw speed requires guru level skill and a lot of
development time. So if you measure speed in terms of productivity
Python is already faster than Java!

But your concerms are misplaced.
All programming languages (except perhaps COBOL and FORTRAN)
come and go. When I left university (mid 1980's) everyone was using
Pascal and C. ADA and Prolog were the forecast kings of the block
and a few people were playing with Smalltalk.Then Windows came out
and C++ suddenly took over. Then it was Java.Then scripting languages
became poular. I don;t know what we will be using in 20 years time but
it probavbly won't be Java or C++ or even Python.Get used to it, as a
professional you will learn and use many languages (I know over 20 that
I've used in real projects, and probavbly another dozen that I studied
just for the knowledge they gave). Languages are just not that important.

Stop fiocussing on languages, start to focus on the deeper
fundamentals of programming. Design, architecture, state, data
structures, logic coupling, cohesion, concurrency etc
These things do not change.

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor