Re: [Tutor] os.path.exists(path) returns false when the path actually exists!

2007-07-28 Thread Hugo González Monteverde
Iyer wrote:
> 
> Adam wrote:
> 
>  From the library documentation:
> Return True if path refers to an existing path. Returns False for
> broken symbolic links. On some platforms, this function may return
> False if permission is not granted to execute os.stat() on the
> requested file, even if the path physically exists.
> 
> So the better question is, does is this file a broken symbolic link or
> can os.stat() be executed on it?
> 
> 
> How do I find if it is a broken symbolic link in Windows 2000 ?
> 
> os.stat(path) returns an OSError saying that there is no such file or 
> directory

Just to check, try to do away with the backslashes. Windows will accept 
a path with forward slashes just as well:

os.path.exists("c:/winnt/file_name")

Hugo
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



Barton David wrote:
> Eric Brunson wrote:
>> You seem like a smart guy that's having a bad day, so I'm cutting you
>> slack.
>  
> Thanks Eric. Yes I did indeed have a bad day (and it got much much worse),
> and this is most definitely a case of a bad workman blaming his tools. I
> apologise to all concerned for voicing my frustrations: it was clearly
> ill-advised.
> Still.. call me idealistic but I feel like a good toolmaker should try
> to listen to her
> clients.

Believe me, the Python developers are sure listening. Only that
"cleaning up the mess" has associated costs, that are usually not
acceptable. If it comes to "not breaking existing programs" or "cleaning
up the stdlib so it's nicer", "not breaking existing programs" is way
higher priority. There are also a number of things to consider:

a) adding a keyword is less of an issue, as breaks programs potentially
with SyntaxErrors before they run. Easy to notice, and easy to fix usually.

b) adding a name in some module is usually not a problems. The only
issue could be imports like that:
   abc = 1
   from module import *
where module adds "abc" would clobber the abc in the customer module.
OTOH, there are really few modules where it is considered usual and ok
to use the star form of import.

c) removing (or renaming, as that removes the old name too) in the
library breaks programs, and worse it breaks them only when the name is
used. Despite rigorous testing, you cannot catch these every time.

So the above observations explain why there is an urllib and urllib2,
removing urllib would imply that many many programs would break. Worse
some would break in production. (btw, some functions in urllib are still
not duplicated, so just removing urllib wouldn't be an option anyway)

So I have to ask all the nice-to-the-newbie guys, what is your take on
this? Should we break existing and deployed applications, so that the
stdlib can look nicer to a newbie? And that is an issue, less for
Windows where one has to install Python yourself, but on Linux boxes one
usually uses the OS provided python version. One fast apt-get upgrade,
and deployed application can trip over any incompatibilities.

>  
> I am not a dedicated programmer. I have other stuff on my plate. I probably
> wouldn't be a programmer at all if Python wasn't (in the early stages) so
> fabulously friendly.

It's still fabulously newbie friendly. And that's why it's one of the
languages that many non-developers are using, usually engineers and
scientists. :)

Andreas
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGqvgHHJdudm4KnO0RAgeLAJ9MZmtpy6rFmdDp/Oh2BrSZLs16GwCbBJzr
LQyRTHL+egu6qVeI0Dh2sBY=
=Miln
-END PGP SIGNATURE-
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] ideas for college app.

2007-07-28 Thread Shriphani Palakodety
Hello all,
I am looking for a few ideas for my college app. Can someone give me a 
few ideas i could work on? I would like to use these to learn more of 
python and to become a true expert at it.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sum of Scores

2007-07-28 Thread Luke Paireepinart
On 7/27/07, Tiger12506 <[EMAIL PROTECTED]> wrote:
>
> Hmmm... interesting tie to another post...
>
> >>> x = timeit.Timer('random.random()','import random')
> >>> x.timeit(300)
> 1.0161026052194018
> >>> y = timeit.Timer('random()','from random import random')
> >>> y.timeit(460)
> 1.0004307810070827
>
> Dictionary lookups do take HUGE amounts of time. Interesting.
>
> Anyway... I've got it down to
> Your numbers with a little more precision gave me
> 3.4e5987 yrs.
>
> and mine
>
> 3.0e5987 yrs.
>
> That's a hell of a lot of years! Remember that everyone! If you want your
> code to run forever and to eternity, copy variables to the local namespace
> first; you get a lot more accomplished (well... whatever);-)
>
> Anyway, the frivolity aside, I can get it to repeat every ten seconds. ;-)
> Set the computer clock. (okay, maybe i'm just in a silly mood. But
> seriously,
> that's why the docs say that it is NOT meant for cryptography - not that
> that matters
> to the OP, snicker; What have I been drinking)
>
> > Well, I was trying to emphasize that it was, for pretty much all intents
> > and purposes, infinite.
>
> Nope-nope-nope you're wrong :-)~


The way I understood the 'period' of the  random function was that after x
calls to the function, you would start getting the same pattern of results
as you did to begin with, in _the same running process_ of a program.
This is a separate situation from having the clock be exactly the same and
getting the same random values on program start - we already knew that would
happen, because the seed hadn't changed.
Unless I understand the period wrong, but I don't think so.

The daring cracker enters the room, his heart quickening as the door hinge
> creaks with the sound of the smallest ever mouse. His dark clothing masks
> him from the lit room visible through the window on the adjacent wall. A
> woman, working late, sits in a comfortable office chair, her face glowing
> from the reflection of her computer screen. A cup of Java (pun intended)
> indicates to anyone watching that she is overworked, and under-paid.
>
> Each step he takes brings him closer to his target. The big boss gave him
> a
> pay cut so that this new PC could sit on his boss's desk. The cracker's
> jealously seems to almost permeate the room. Vengeance shouts out louder
> than the compressor of the air conditioner in the north window. The
> cracker
> intinctively looks up to see if his emotions betrayed his presence. But
> the
> woman in the other room continues her scrolling through endless lines of
> buggy, hard to read, unmaintainable, bloated, and otherwise ridiculously
> foolish code that could have been so easily fixed if the same 'big boss'
> had
> ordered the project in Python.
>
> Soon, a floppy disk is pulled out of a black jacket pocket. No one has
> ever
> run the program on the floppy before. Taking the disk, the cracker inserts
> it into the drive, starts the machine, swears under his breath when he
> reads
> "Non-System disk or disk error. Replace and strike any."
>
> Striking the 'any' key, he quickly shoves the floppy disk back in. He
> wants
> this over with. Again, he looks to see if he has been detected; still he
> is
> safe. Opening the folder containing the floppy drive, he groans silently
> as
> the annoying Windows Firewall flashes an update notice. "See..." he thinks
> to himself, "Micro$oft *can* actually restrict viruses from entering their
> OS." He fights with the window, impatiently waiting for countless
> libraries
> to load and free, until the UI responds and he can send it a WM_CLOSE
> message.
>
> Smirking evily, the cracker double-clicks the executable
> 'pink_fuzzy_bunny.exe' and resists the urge to laugh maniacally as he
> watches the computer clock freeze and not move. Ingenious--his plan--All
> it
> takes to freeze time is to contantly set it to the same second in history.
> Time. Forever frozen. He frowns as he realizes that in so doing, he
> provides
> the only effective means for keeping those pesky Windows notices out of
> his
> boss's hair. "No matter" --he thinks, "He will have worse troubles in due
> time." Again he suppresses a maniacal laugh.
>
> . . .
>
> Monday morning brings a bright and cheerful man into an office, his
> office.
> The door creaks a little as he opens it, and the air conditioner buzzing
> in
> the north wall window is refreshing to him after the heat from outside.
> The
> man waves cheerfully at a woman through the glass in the adjacent wall,
> whom
> looks up only for an instant to scowl. The man, who recently bought his
> new
> PC, smiles proudly as he turns it on. His new python program which he
> keeps
> on the desktop is his early attempt at a cricket game simulation. He
> lovingly double-clicks the icon, and runs the program several times. Each
> successive time his grin grows smaller and smaller until his face is more
> than troubled. Why is his program producing the same output every time? A
> scream is heard

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Kent Johnson
Andreas Kostyrka wrote:

> Believe me, the Python developers are sure listening. Only that
> "cleaning up the mess" has associated costs, that are usually not
> acceptable. If it comes to "not breaking existing programs" or "cleaning
> up the stdlib so it's nicer", "not breaking existing programs" is way
> higher priority. 

FWIW there is talk of some minor cleanup of the library for Python 3000:
http://www.python.org/dev/peps/pep-3001/
http://www.python.org/dev/peps/pep-3108/

These are very modest changes - primarily removing obsolete modules and 
cleaning up the names to match current conventions.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] putting python to use

2007-07-28 Thread Kent Johnson
chris harvey wrote:
> Hi,
> I am very very new to python language. if this is to
> simple im sorry. I have had linux mandrake for 2 weeks
> now and i have been learning. 
> I got my apache server running to find it has no GUI.
> I was disapointed till i remembered i was learning
> python. 
> I wondered if a python script could be used to make
> /combind the server start and the config file take
> info from the script. that make sense? 
> something like.
> 
> 
> /usr/sbin/advxrun2.0 # starts server then
> open (path) apache.config for input ?
> 

I don't really understand what you want to do. If you want to write a 
script that runs other programs, look at os.system()
http://docs.python.org/lib/os-process.html#l2h-2761

What do you mean by "open (path) apache.config for input" ?

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Alan Gauld
"Andreas Kostyrka" <[EMAIL PROTECTED]> wrote

>> a lot to build the Tacoma Narrows bridge... Similarly you don't 
>> need
>> much math to build a GUI friont end to a database, but you need
>
> I would question even that one can write a good GUI frontend to a
> database without the theory behind it. Database design has a number 
> of
> important theoretical foundations 

But the math is in the design of the database. If it already exists 
the
GUI design is usually more a matter of good usability design. There
might be a bit of SQL going on but usually a data browser GUI doesn't
need anything sophisticated, that should be hidden in an application
(with API) or in a set of stored proceduresbin the database itself.

> Well, the advanced stuff was there. But the Modula2 introduction to
> programming was a joke, most students did not even understand the
> concept of local variables and procedure parameters after one 
> semester.

Thats bad. As I say our Pascal course was a fairly dull but complete
introduction to elementary programming including file handling and
dynamic data structures. Our final program was Conways game of Life
which had to be able to be paused and saved to disk, and later
restored...

Ahhh, the memories!

Alan G. 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] os.path.exists(path) returns false when the pathactually exists!

2007-07-28 Thread Tiger12506
> Adam wrote:
>
>>From the library documentation:
> Return True if path refers to an existing path. Returns False for
> broken symbolic links. On some platforms, this function may return
> False if permission is not granted to execute os.stat() on the
> requested file, even if the path physically exists.
>
> So the better question is, does is this file a broken symbolic link or
> can os.stat() be executed on it?
>
> How do I find if it is a broken symbolic link in Windows 2000 ?
>
> os.stat(path) returns an OSError saying that there is no such file or 
> directory

Wow. I've never heard of this. What are the file's attributes? What does it 
say about the file when you right-click Properties? Hmmm... what's going on 
here? Permission not granted to execute os.stat()? Why wouldn't anyone have 
permission to do that?

A broken symbolic link... That means a hard link that has been cut-off 
right? (Hard-links are like pointers to files in NTFS)  ~ so if the file's 
been moved, that hard link will point to nothing, being broken, right? Does 
anyone know about this? I'm curious.

JS 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] putting python to use

2007-07-28 Thread Tiger12506
>> 
>> /usr/sbin/advxrun2.0 # starts server then
>> open (path) apache.config for input ?
>> 
>
> I don't really understand what you want to do. If you want to write a
> script that runs other programs, look at os.system()
> http://docs.python.org/lib/os-process.html#l2h-2761
>
> What do you mean by "open (path) apache.config for input" ?
>
> Kent

Well, assuming that he wants to Open apache.config for input, I would guess 
that he needs to be able to open the file, and be able to parse it's 
contents. If that's the case, a sample of the contents would be nice~ most 
config files are alike, but there are a few gotchas out there.

JS 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sum of Scores

2007-07-28 Thread Tiger12506
>> > Well, I was trying to emphasize that it was, for pretty much all 
>> > intents
>> > and purposes, infinite.
>>
>> Nope-nope-nope you're wrong :-)~
>
>
> The way I understood the 'period' of the  random function was that after x
> calls to the function, you would start getting the same pattern of results
> as you did to begin with, in _the same running process_ of a program.
> This is a separate situation from having the clock be exactly the same and
> getting the same random values on program start - we already knew that 
> would
> happen, because the seed hadn't changed.
> Unless I understand the period wrong, but I don't think so.

No, you understand it just fine. The story was to illustrate the special 
case. It has nothing to do with whether or not it's the same running 
process. Two process started within the same second produce the same 
'random' results. So, as the story goes, the big boss's computer time is 
locked, runs for *nearly* an eternity, and at that point the pattern starts 
repeating.

I was just being nit-picky and silly. I told you it was late :-)

 > as a side note - are you going to enter the September Pyweek?  You 
should!
> It's a lot of fun.
> -Luke

Hmmm what's that? I'll google.

JS 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Eric Brunson
Alan Gauld wrote:
> "Andreas Kostyrka" <[EMAIL PROTECTED]> wrote
>
>   
>>> a lot to build the Tacoma Narrows bridge... Similarly you don't 
>>> need
>>> much math to build a GUI friont end to a database, but you need
>>>   
>> I would question even that one can write a good GUI frontend to a
>> database without the theory behind it. Database design has a number 
>> of
>> important theoretical foundations 
>> 
>
> But the math is in the design of the database. If it already exists 
> the
> GUI design is usually more a matter of good usability design. There
> might be a bit of SQL going on but usually a data browser GUI doesn't
> need anything sophisticated, that should be hidden in an application
> (with API) or in a set of stored proceduresbin the database itself.
>   

I'm definitely a believer that if you get the data model correct first, 
the software almost writes itself.  I've usually found that when I have 
trouble accessing the data I want, I didn't design the schema correctly.

>   
>> Well, the advanced stuff was there. But the Modula2 introduction to
>> programming was a joke, most students did not even understand the
>> concept of local variables and procedure parameters after one 
>> semester.
>> 
>
> Thats bad. As I say our Pascal course was a fairly dull but complete
> introduction to elementary programming including file handling and
> dynamic data structures. Our final program was Conways game of Life
> which had to be able to be paused and saved to disk, and later
> restored...
>
> Ahhh, the memories!
>
> Alan G. 
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>   

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] os.path.exists(path) returns false when the pathactually exists!

2007-07-28 Thread Thorsten Kampe
* Tiger12506 (Sat, 28 Jul 2007 10:33:36 -0500)
> > So the better question is, does is this file a broken symbolic link or
> > can os.stat() be executed on it?
> >
> > How do I find if it is a broken symbolic link in Windows 2000 ?
> >
> > os.stat(path) returns an OSError saying that there is no such file or 
> > directory
> 
> Wow. I've never heard of this. What are the file's attributes? What does it 
> say about the file when you right-click Properties? Hmmm... what's going on 
> here? Permission not granted to execute os.stat()? Why wouldn't anyone have 
> permission to do that?
> 
> A broken symbolic link... That means a hard link that has been cut-off 
> right?

No, symbolic links and hard links are totally different.

> (Hard-links are like pointers to files in NTFS)  ~ so if the file's 
> been moved, that hard link will point to nothing, being broken, right?

Thre are no "broken hard links"...

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Thorsten Kampe
* Kent Johnson (Fri, 27 Jul 2007 08:06:33 -0400)
> Barton David wrote:
> > *sigh* I'm really going off Python.
> 
> In what way is it Python's fault that the dbm database doesn't reclaim 
> disk space?

It's actually how most databases work. Even a simple Outlook pst file 
(which is a database, too) works this way. I thought everyone knows or 
heard about this.

Thorsten

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] build a really simple "json" api from a db

2007-07-28 Thread Picio
Hello, I'd like to know the necessary steps to build a json api for
two table on my db.
The design will be: an ajax app asking for data to my server, that
fetches those data from a db then build the answer in json.
Ajax n the client will then use json data to do some staff.
I'd like to build this API in python.
What pieces of software I need? (simplejson?)

I've seen this snippet on the djangosnippet site.
http://www.djangosnippets.org/snippets/154/
Is It the right way.
Daniele

-- 
http://picio.gotdns.com ...Il mio blog su NSLU2
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] build a really simple "json" api from a db

2007-07-28 Thread Alan Gauld

"Picio" <[EMAIL PROTECTED]> wrote

> Hello, I'd like to know the necessary steps to build a json api for
> two table on my db.

Since you seem to be using Django are you sure that isn't built in?

I use Turbo Gears and JSON is a standard feature turned on by
an option in a method. Django is quite similar to TG in most respects
so I'll be surprised if it can't do JSON directly.

> I've seen this snippet on the djangosnippet site.
> http://www.djangosnippets.org/snippets/154/
> Is It the right way.

If its on the Django web site and you are using Django then
probably! :-)

It certainly looks like a recommendation to me.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Eric Brunson
On Sat, July 28, 2007 4:01 am, Thorsten Kampe wrote:
> * Kent Johnson (Fri, 27 Jul 2007 08:06:33 -0400)
>
>> Barton David wrote:
>>
>>> *sigh* I'm really going off Python.
>>>
>>
>> In what way is it Python's fault that the dbm database doesn't reclaim
>> disk space?
>
> It's actually how most databases work. Even a simple Outlook pst file
> (which is a database, too) works this way. I thought everyone knows or
> heard about this.

I don't even think mysql reclaims disk space unless you intervene.




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] comparing lists, __lt__ and __gt__

2007-07-28 Thread Sara Johnson
First off, Kent, thanks for posting that!  I know it's in the Python library 
but it does help to have a bookmark for things I know I'll need pretty soon.

Second...  What if there is a '<<' or '>>'?  Does that just mean the same thing 
(maybe a little over emphasized..  ;)   I thought I saw this when I was 
learning boolean expressions, but I don't recall.


- Original Message 
From: Kent Johnson [EMAIL PROTECTED]


Good question! The only doc I can find on this behavior is this:
http://docs.python.org/lib/comparisons.html

which just says that the comparison operation exists. There doesn't seem 
to be any documentation on how comparison works with sequences.

I think it is pretty safe to count on the current behaviour of < and > 
for lists. I'll put in a documentation bug on this - the meaning of 
these operations (and ==) should be explicit in the docs.

Kent


   

Get the free Yahoo! toolbar and rest assured with the added security of spyware 
protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



Eric Brunson wrote:
> On Sat, July 28, 2007 4:01 am, Thorsten Kampe wrote:
>> * Kent Johnson (Fri, 27 Jul 2007 08:06:33 -0400)
>>
>>> Barton David wrote:
>>>
 *sigh* I'm really going off Python.

>>> In what way is it Python's fault that the dbm database doesn't reclaim
>>> disk space?
>> It's actually how most databases work. Even a simple Outlook pst file
>> (which is a database, too) works this way. I thought everyone knows or
>> heard about this.
> 
> I don't even think mysql reclaims disk space unless you intervene.

As this thread got already very philosophical, I'd like to add that the
jury is still out if mysql is a RDBMS. I personally interpret it as a
datafile access library that tries to pretend to be a database system :)

Andreas
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGq7m7HJdudm4KnO0RAr6CAKCTSLxA5blSX19IVfpN1RVywRZvSACghExR
iRDi3pk+NBPhIcQdd1QkP70=
=eS7Q
-END PGP SIGNATURE-
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] comparing lists, __lt__ and __gt__

2007-07-28 Thread Alan Gauld

"Sara Johnson" <[EMAIL PROTECTED]> wrote

> What if there is a '<<' or '>>'?
> Does that just mean the same thing (maybe a little over emphasized.. 
> ;)

The double chevron operator is for bit-shifting its not a camparison 
operation.
So no operator override function exists.

> I thought I saw this when I was learning boolean expressions,
> but I don't recall.

Possibly, because its often used to manipulate bitpatterns in
conjunction with bitwise boolean comparisons (and/or/xor etc)

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Alan Gauld

"Eric Brunson" <[EMAIL PROTECTED]> wrote
> On Sat, July 28, 2007 4:01 am, Thorsten Kampe wrote:
>>> In what way is it Python's fault that the dbm database doesn't 
>>> reclaim
>>> disk space?
>>
>> It's actually how most databases work. Even a simple Outlook pst 
>> file
>> (which is a database, too) works this way. I thought everyone knows 
>> or
>> heard about this.
>
> I don't even think mysql reclaims disk space unless you intervene.

Its actually more efficient for databases to do this, because when 
they
grow beyond the size of the file they need to reallocate extra disk
space which is slow but because they hold onto space from deleted
records the space is usually there ready for reuse. Unix does the
same thing with RAM too. If you run a process which grabs lots of
memory and then frees it again you will see the process memory
useage climb, but never drop! This can be a problem if the process
grabs a lot of RAM on initialisation but then frees it all up again
during normal operation. We used to have a GUI that grabbed
around 200MB on startup but actually only used around 8-12 in
normal use, but its memory footprint was alway 200M!

HTH,

Alan G. 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] comparing lists, __lt__ and __gt__

2007-07-28 Thread Sara Johnson
Thanks Alan.  That said, any idea what it means in this context?

for key in skeys:
fracmiss=1.*numberMissing(z[key].values())/nsites #note decimal 
multiplication, 1.*
outstring="%s has %4.1f%% missing" % (key,100*fracmiss)
if fracmiss >>0




- Original Message 
From: Alan Gauld <[EMAIL PROTECTED]>
To: tutor@python.org
Sent: Saturday, July 28, 2007 5:03:05 PM
Subject: Re: [Tutor] comparing lists, __lt__ and __gt__


"Sara Johnson" <[EMAIL PROTECTED]> wrote

> What if there is a '<<' or '>>'?
> Does that just mean the same thing (maybe a little over emphasized.. 
> ;)

The double chevron operator is for bit-shifting its not a camparison 
operation.
So no operator override function exists.

> I thought I saw this when I was learning boolean expressions,
> but I don't recall.

Possibly, because its often used to manipulate bitpatterns in
conjunction with bitwise boolean comparisons (and/or/xor etc)

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


   

Be a better Heartthrob. Get better relationship answers from someone who knows. 
Yahoo! Answers - Check it out. 
http://answers.yahoo.com/dir/?link=list&sid=396545433___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] comparing lists, __lt__ and __gt__

2007-07-28 Thread Alan Gauld

"Sara Johnson" <[EMAIL PROTECTED]> wrote

> Thanks Alan.  That said, any idea what it means in this context?
>
> for key in skeys:
>fracmiss=1.*numberMissing(z[key].values())/nsites #note 
> decimal multiplication, 1.*
>outstring="%s has %4.1f%% missing" % (key,100*fracmiss)
>if fracmiss >>0

None whatsoever, it looks like an error to me!

That having been saisd their is another use for >> which is to append
output to a file, as in:

print 'hello world' >> myfile

sends the string to myfile instead of to stdout. (Although I couldn't 
get this to
work when I tried it!)

Alan G.



- Original Message 
From: Alan Gauld <[EMAIL PROTECTED]>
To: tutor@python.org
Sent: Saturday, July 28, 2007 5:03:05 PM
Subject: Re: [Tutor] comparing lists, __lt__ and __gt__


"Sara Johnson" <[EMAIL PROTECTED]> wrote

> What if there is a '<<' or '>>'?
> Does that just mean the same thing (maybe a little over emphasized..
> ;)

The double chevron operator is for bit-shifting its not a camparison
operation.
So no operator override function exists.

> I thought I saw this when I was learning boolean expressions,
> but I don't recall.

Possibly, because its often used to manipulate bitpatterns in
conjunction with bitwise boolean comparisons (and/or/xor etc)

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor




Be a better Heartthrob. Get better relationship answers from someone 
who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545433





> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sum of Scores

2007-07-28 Thread Luke Paireepinart
Tiger12506 wrote:
 Well, I was trying to emphasize that it was, for pretty much all 
 intents
 and purposes, infinite.
 
>>> Nope-nope-nope you're wrong :-)~
>>>   
>> The way I understood the 'period' of the  random function was that after x
>> calls to the function, you would start getting the same pattern of results
>> as you did to begin with, in _the same running process_ of a program.
>> This is a separate situation from having the clock be exactly the same and
>> getting the same random values on program start - we already knew that 
>> would
>> happen, because the seed hadn't changed.
>> Unless I understand the period wrong, but I don't think so.
>> 
>
> No, you understand it just fine. The story was to illustrate the special 
> case. It has nothing to do with whether or not it's the same running 
> process. Two process started within the same second produce the same 
> 'random' results. So, as the story goes, the big boss's computer time is 
> locked, runs for *nearly* an eternity, and at that point the pattern starts 
> repeating.
>   
So normally, after the period is up, it would choose a new seed? or does 
it repeat after the period whether or not the time has changed?

> I was just being nit-picky and silly. I told you it was late :-)
>
>  > as a side note - are you going to enter the September Pyweek?  You 
> should!
>   
>> It's a lot of fun.
>> -Luke
>> 
>
> Hmmm what's that? I'll google.
>   
It's a whole lot of fun.  And everyone's really nice.
SO even if you don't have time to finish a game, it's enjoyable and a 
learning experience just to
hang out with everyone on IRC.  Also, you should have time to learn 
pygame for the competition if you don't know how to use it already.  Of 
course you could use pyglet or pyOpenGL or something instead, if you wanted.
> JS 
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>   

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Livewires questions

2007-07-28 Thread Luke Paireepinart
Luke Paireepinart wrote:
>
>
> I ran the code that you had included, thank you for this.  It did
> produce the player and the robot on the grid, but the keyboard
> commands
> did not work.  I wasn't entire sure why, but I thought I would let
> you know.
>
>
> Sure, sure.  I'm glad it at least ran.  I don't have livewires 
> installed so I wasn't able to test any of the code I wrote.
>
> Thanks again for your help.  If you have suggestions on the 't' key,
> please share them.  This seems to be the one issue preventing me from
> going forward.
>
>
> I need to go to sleep right now, but tomorrow afternoon I should have 
> some free time and if so, I'll install livewires and give you more 
> suggestions.
>
> Tonu
>
>
Actually, I may not have time for this after all.  I'm in the final 
throes of a Differential Equations class (it's really accelerated to fit 
all in one month) and even on weekends I have to study for it.  Luckily 
it's done in 9 class days (we do class 12-1:40 M-F, so that puts the 
Final on Thursday) so I will gladly offer any help you need after that time.
But until then, I'm not sure when I'll be able to do anything.
P.S. I forgot to hit reply-all on the previous e-mail, which is why I 
left it intact.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Eric Brunson
Andreas Kostyrka wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
>
>
> Eric Brunson wrote:
>   
>> On Sat, July 28, 2007 4:01 am, Thorsten Kampe wrote:
>> 
>>> * Kent Johnson (Fri, 27 Jul 2007 08:06:33 -0400)
>>>
>>>   
 Barton David wrote:

 
> *sigh* I'm really going off Python.
>
>   
 In what way is it Python's fault that the dbm database doesn't reclaim
 disk space?
 
>>> It's actually how most databases work. Even a simple Outlook pst file
>>> (which is a database, too) works this way. I thought everyone knows or
>>> heard about this.
>>>   
>> I don't even think mysql reclaims disk space unless you intervene.
>> 
>
> As this thread got already very philosophical, I'd like to add that the
> jury is still out if mysql is a RDBMS. I personally interpret it as a
> datafile access library that tries to pretend to be a database system :)
>   

I had 13 years of Oracle experience under my belt when I tried MySQL 
version 3.x.  Then it was a toy database and barely worth my attention.  
We're now using 5.0 and it is definitely no longer simply pretending to 
be a database. 

At work we have a system that is storing over 1.5 billion records and 
makes our Oracle installations pale in comparison.  Another system is 
running distributed in a cluster running multiple masters in ring 
replication.  Oracle was either impressed or threatened enough to buy 
the rights to InnoDB, that has to say something about the state of 
MySQL.  With the addition of stored procedures, triggers and views in 
5.0, it has definitely met all but my most esoteric needs.

I'm not saying MySQL is perfect, I have several bugs and feature 
requests logged with MySQL that I'm still waiting to be addressed, but 
if you haven't used it lately, you're missing out.


> Andreas
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.2 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFGq7m7HJdudm4KnO0RAr6CAKCTSLxA5blSX19IVfpN1RVywRZvSACghExR
> iRDi3pk+NBPhIcQdd1QkP70=
> =eS7Q
> -END PGP SIGNATURE-
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>   

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ideas for college app.

2007-07-28 Thread Bob Gailer
Shriphani Palakodety wrote:
> Hello all,
> I am looking for a few ideas for my college app. Can someone give me a 
> few ideas i could work on? I would like to use these to learn more of 
> python and to become a true expert at it.
>   
I don't understand what you want. Probably others also don't, as there 
has been no response.

Could you be a lot more explicit?


-- 
Bob Gailer
510-978-4454 Oakland, CA
919-636-4239 Chapel Hill, NC


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ideas for college app.

2007-07-28 Thread Dick Moores
At 03:02 AM 7/28/2007, Shriphani Palakodety wrote:
>Hello all,
>I am looking for a few ideas for my college app. Can someone give me a
>few ideas i could work on? I would like to use these to learn more of
>python and to become a true expert at it.

Are there any set requirements for your "college app"? What does 
"college app" mean?

Dick Moores


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] attribute error

2007-07-28 Thread Sara Johnson
I thought 'sort()' was a function you could use as long as the dict or key had 
some value.  When is this not right?


  

Park yourself in front of a world of choices in alternative vehicles. Visit the 
Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/ ___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] attribute error

2007-07-28 Thread Bob Gailer
Sara Johnson wrote:
> I thought 'sort()' was a function you could use as long as the dict or 
> key had some value.  When is this not right?
Please give us some context for the question. Code fragment, traceback.

sort is a method of mutable sequence types (lists, ...)

myList = [1, 3, 2]
myList.sort() # returns None
print myList
[1, 2, 3]


-- 
Bob Gailer
510-978-4454 Oakland, CA
919-636-4239 Chapel Hill, NC


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] attribute error

2007-07-28 Thread Sara Johnson
I scrapped that other attempt.  I keep hitting brick walls.

However, is there an indentation error here?  I may just be too frustrated to 
see it.

for key in skeys:
fracmiss=1.*numberMissing(z[key].values())/nsites #note decimal 
multiplication, 1.*
outstring="%s has %4.1f%% missing" % (key,100*fracmiss)
if fracmiss>0.:
print outstring





- Original Message 
From: Bob Gailer <[EMAIL PROTECTED]>
To: Sara Johnson <[EMAIL PROTECTED]>
Cc: Python 
Sent: Saturday, July 28, 2007 10:14:58 PM
Subject: Re: [Tutor] attribute error


Sara Johnson wrote:
> I thought 'sort()' was a function you could use as long as the dict or 
> key had some value.  When is this not right?
Please give us some context for the question. Code fragment, traceback.

sort is a method of mutable sequence types (lists, ...)

myList = [1, 3, 2]
myList.sort() # returns None
print myList
[1, 2, 3]


-- 
Bob Gailer
510-978-4454 Oakland, CA
919-636-4239 Chapel Hill, NC


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


   

Choose the right car based on your needs.  Check out Yahoo! Autos new Car 
Finder tool.
http://autos.yahoo.com/carfinder/___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] attribute error --Disregard

2007-07-28 Thread Sara Johnson
Disregard this post.  Sorry for the added message in everyone's inbox.


- Original Message 
From: Sara Johnson <[EMAIL PROTECTED]>
To: Python 
Sent: Saturday, July 28, 2007 11:19:15 PM
Subject: Re: [Tutor] attribute error


I scrapped that other attempt.  I keep hitting brick walls.
 
However, is there an indentation error here?  I may just be too frustrated to 
see it.
 
for key in skeys:
fracmiss=1.*numberMissing(z[key].values())/nsites #note decimal 
multiplication, 1.*
outstring="%s has %4.1f%% missing" % (key,100*fracmiss)
if fracmiss>0.:
print outstring
 

 

 
- Original Message 
From: Bob Gailer <[EMAIL PROTECTED]>
To: Sara Johnson <[EMAIL PROTECTED]>
Cc: Python 
Sent: Saturday, July 28, 2007 10:14:58 PM
Subject: Re: [Tutor] attribute error


Sara Johnson wrote:
> I thought 'sort()' was a function you could use as long as the dict or 
> key had some value.  When is this not right?
Please give us some context for the question. Code fragment, traceback.

sort is a method of mutable sequence types (lists, ...)

myList = [1, 3, 2]
myList.sort() # returns None
print myList
[1, 2, 3]


-- 
Bob Gailer
510-978-4454 Oakland, CA
919-636-4239 Chapel Hill, NC


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor





Shape Yahoo! in your own image. Join our Network Research Panel today!


   

Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.com/___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor