[Tutor] Re: This Deletes All my Files

2005-02-04 Thread Andrei
ests/test.txt w dummyfile.open: ('d:/tests/test.txt', 'w') <--- first open for writing dummyopen: d:/tests/test.txt r dummyfile.open: ('d:/tests/test.txt', 'r') <--- then for reading dummyfile.read: () dummyfile.write: ('',) > spend 5 hours RTFM. I got

[Tutor] Re: Small GUI toolkit and executable creators

2005-02-04 Thread Andrei
, and there's only so much compressing you can do. -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb gurer'f ab arrq gb PP. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: Negative IF conditions

2005-02-11 Thread Andrei
Mark Brown wrote: I'm a newbie and was wondering which of these IF conditions is better structure: 1. if not os.path.exists('filename'): 2. if os.path.exists('filename') == False: I prefer the "if not" variety. Yours, Andrei ___

[Tutor] Re: References in loops

2005-02-12 Thread Andrei
aList = [elem+1 for elem in aList] but it's barely shorter than the explicit loop, so not necessarily an improvement from that point of view. But at least it prevents the bug from biting :). Yours, Andrei ___ Tutor maillist - Tutor@python.org

[Tutor] Re: Accessing local variables from nested functions.

2005-02-13 Thread Andrei
? I'd use return in the form of def p(): v = 3 def q(): return v+1 v = q() If you need to modify a lot of p-vars inside q, I'd say it's probably wiser to go with a class and appropriate methods. -- Yours, Andrei = Real contact info (decode with rot13): [EM

[Tutor] Re: Active Python

2005-02-17 Thread Andrei
know if it also includes Dive into Python, FAQ's and HowTo's like the ActiveState one does. It's nothing that you can't download on your own for free, but it's just more comfortable to get it all in a single package. Andrei __

[Tutor] Re: Class in a class

2005-02-18 Thread Andrei
= [] for line in self.lines: for point in line.points: if point not in self.points: self.points.append(point) And you could go even higher, to a tetraeder made out of triangles, if you extended Point

[Tutor] Re: Functions Calling Functions

2005-02-25 Thread Andrei
'map', since you just have to modify the data. Modifying data is safer and easier than modifying code. - it's easier to debug than when you have a billion lines of call stack. - I expect it to consume less memory -- Yours, Andrei = Real contact info (decode with rot13): [E

[Tutor] Re: Newbie simple question

2005-02-25 Thread Andrei
ad/skip lines manually as needed. -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb gurer'f ab arrq gb PP. ___ Tutor maillist - Tut

[Tutor] Re: Linked List

2005-03-04 Thread Andrei
xt >>> a = node('item a') >>> b = node(3) >>> c = node((3,4)) >>> d = node('last item') >>> a.next = b >>> b.next = c >>> c.next = d >>> mynode = a >>> while mynode: ... print mynode.item ... myn

[Tutor] Re: Re: Q & A

2005-03-04 Thread Andrei
omework for me". -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb gurer'f ab arrq gb PP. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: xmlrpc server

2005-03-24 Thread Andrei
it's reasonably easy to replace it with something else later. For example 20 MB memory use doesn't sound like much to me on a modern computer, but I'd leave Nevow out of the choice of your XMLRPC server. -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROT

[Tutor] Re: Module Loop doesn't work (Joseph Q.)

2005-04-01 Thread Andrei
in turn be another loop accepting words as input which get 'translated', until the user gives a blank string or whatever as input in order to terminate the loop (and automatically fall back into the loop of the lobby) -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL

[Tutor] Re: Self referencing within a dictionary

2005-04-02 Thread Andrei
But I also can't imagine right now any realistic cases where it would be useful to have a dictionary contain itself as a value. -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfg

[Tutor] Re: Re: Self referencing within a dictionary

2005-04-03 Thread Andrei
John Fouhy wrote on Sun, 03 Apr 2005 09:53:56 +1200: > Andrei wrote: >> Liam Clarke wrote on Sat, 2 Apr 2005 22:12:49 +1200: >>>I know that as above doesn't work, but was just wondering if it's >>>possible, and if it's a Bad Thing? >> Max has alrea

[Tutor] Re: one line code

2005-04-04 Thread Andrei
t; globals(),locals()'%(s,s),'','exec')),t)[1] for s in l] [1.0, 2.0, 3.0, 'abc', '', 4.0, 9.5, 9.0] I would recommend against it though :). Having a special function for this purpose is the way to go, a ternary operator doesn't really add any

[Tutor] Re: building strings of specific length

2005-04-04 Thread Andrei
eep it readable): >>> s = "%20s" % "xyz" >>> len(s), s (20, ' xyz') or: >>> s = "xyz" >>> s = s + (20 - len(s)) * ' ' >>> s, len(s) ('xyz ', 20) -- Yours, And

[Tutor] Re: one line code

2005-04-05 Thread Andrei
numbers stored as strings :). Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: Mouseclick

2005-04-06 Thread Andrei
age). If you pass that parameter in the SendMessage calls, I think the mouse should click on a certain position (although I haven't tested, as I'm not on Windows ATM). Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: Help with classes

2005-04-07 Thread Andrei
he player is in plus the connected rooms), an Item class (with subclasses for different types of items, where different implementations of e.g. PickUp methods would determine if the player could pick up a pencil or a skyscraper), etc. Yours, Andrei

[Tutor] Re: Help with classes

2005-04-08 Thread Andrei
Bob Gailer alum.rpi.edu> writes: > At 12:22 PM 4/7/2005, Andrei wrote: > >Kevin gmail.com> writes: > > > > > I am fooling around with classes and I was trying to create a very > > > small one player text adventure. I made a class called commands here &g

[Tutor] Re: Help with classes

2005-04-08 Thread Andrei
pick up excalibur even though conan already has it.) You can see that conan and donan are both players (Player objects), but each of them has his own name, inventory and strength. Even if conan's inventory is full, donan can still pick up new things. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: Class - superclass

2005-04-08 Thread Andrei
e the fact that __init__ is indeed inherited: >>> class C(A): ... pass >>> c = C() # inherited __init__ (A.__init__) is called >>> c.a 13 -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V er

[Tutor] Re: Help with classes (Joseph Q.)

2005-04-09 Thread Andrei
ink of an address book (where you use names as keys and addresses as values), a menu system (where certain user input is mapped to a certain function), a cache system (where results of certain time-consuming operations are saved in case the user asks for the same operation again) and there are man

[Tutor] Re: import.... (Joseph Q.)

2005-04-09 Thread Andrei
7;t provide? -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb gurer'f ab arrq gb PP. ___ Tutor maillist - Tutor@python.org http://mail.python.org/

[Tutor] Re: import.... (Joseph Q.)

2005-04-10 Thread Andrei
a more detailed description it's hard to determine. I would say it's perpahs a bit unusual if you do indeed have two modules with the same interface but different behavior. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: Sorting of files based on filesize

2005-04-11 Thread Andrei
erfectly, even though initial random file distributions give 240+ discs), but I haven't checked the results very thoroughly. It might be doing something really stupid. It's also reasonably fast (1000 generations of 1000 individuals each is feasible for example, but not necessarily

[Tutor] Re: sorting a list of dictionaries

2005-04-12 Thread Andrei
s context just a different way of defining a function. The net result is a comparison function which is called by the sort() method in order to determine which of two dictionaries is 'smaller' or 'larger'. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: Python starting books (fwd)

2005-04-12 Thread Andrei
not Python-specific: if they convey their ideas clearly, you can implement such things on your own. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: when to use properties?

2005-04-12 Thread Andrei
y and add the appropriate methods, so that the interface remains the same. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: New to programming question

2005-04-13 Thread Andrei
t does! However, a different test reveals this: >>> d = {4:0, 5:0, 1:0} >>> d.keys() [1, 4, 5] Aha! So it sorts the keys (both tests support this conclusion). Or does it? >>> d = {4:0, -1:0, 5:0} >>> d.keys() [4, 5, -1] Nope, not sorted, not ordered - exactly as the Python specification states, dictionaries are unordered. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: help (fwd)

2005-04-13 Thread Andrei
a plain text generic editor, save the program and double-click on it in Explorer (if you're on Windows) or launch it by typing at the command line: python myscript.py Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: when to use properties?

2005-04-13 Thread Andrei
, but from that point on, it's no longer your responsibility to protect them from themselves. Python works on the assumption that programmers are responsible adults :). Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: (no subject)

2005-04-14 Thread Andrei
t 4 letters, type i[-4:]. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: Craps, eternal loop (Joseph Q.)

2005-04-14 Thread Andrei
ke it a global variable and only initialize it at the start of the program). Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: Recursion....what are the best situations to use it?

2005-04-14 Thread Andrei
ith certain connections between them (if there aren't too many points, otherwise you'll hit a recursion depth limit or a stack overflow). Or for a menu navigation system, where a showmenu() routine calls itself to display submenus. Yours, Andrei ___

[Tutor] Re: high score lists

2005-04-14 Thread Andrei
en then it's still easier to keep them in a list of tuples, because it's easier to do manipulations like "remove the lowest score" when you insert a higher one. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: newbie intro to pickle

2005-04-16 Thread Andrei
> mydb = bsddb.btopen('game.db') >>> pickle.loads(mydb['lastplayer']) 'John Doe' This is not useful for small amounts of data like the highscores list, but if you have more data (e.g. level data, dialog texts) and you need quick access to it without having to keep everything in memory all the time, bsddb is a comfortable option. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: exceptions

2005-04-16 Thread Andrei
erything goes well, you'll get a NameError if you try to print it. Also if it does exist, it will need to be reset before the try-except, otherwise afterwards you won't know whether its value comes from the last try-except or from some time in the past. On a sidenote: recommended Python

[Tutor] Re: newbie intro to pickle

2005-04-16 Thread Andrei
ary and mistakes might lead to breakage) It's quite obvious though that no method is good enough if you attach any kind of value to high scores, by e.g. posting the highest scores on your webpage. Yours, Andrei ___ Tutor maillist - Tutor@python

[Tutor] Re: How can I avoid cut'n'paste in this case?

2005-04-16 Thread Andrei
> always thought it a bad smell. It does indeed smell of a maintenance nightmare waiting to happen :). The bad part is that it tends to get progressively worse. Imagine also what would happen if you'd get even more of those similar modules. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: Installation Routines (Joseph Quigley)

2005-04-18 Thread Andrei
Tkinter wrapper) it would be even absolutely trivial (show a standard directory selection dialog, then copy the stuff - 5 lines of code or so). It would be cross-platform too. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: snippets helps

2005-04-18 Thread Andrei
eful to rise to the top of > the examples? It would indeed, if someone implemented it :). > would get used or not. Perhaps the personal feedback of the tutor list > is more effective. OTOH, finding it yourself is faster than waiting for a reply. Yours, Andrei ___

[Tutor] Re: How to obfuscate a database password. (fwd)

2005-04-19 Thread Andrei
g else - though more obsfucation != more security). The effect this will have in stopping a determined person will be pretty much zero, but at least it's not out there in the open and a simple text search won't cause it to just show up. Yours, Andrei _

[Tutor] Re: Installation Routines (Joseph Quigley) (Jay Loden)

2005-04-22 Thread Andrei
Joseph Quigley wrote on Fri, 22 Apr 2005 13:45:05 -0600: > Interesting. So several distros use rpms? I though only red hat used 'em. Yeah, including some major ones like Mandrake and Suse. -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! C

[Tutor] Re: CLS? (Joseph Quigley)

2005-04-22 Thread Andrei
ce for your application :). Command line apps which wipe out the command line history are bad. You might prefer making a GUI or a web application instead. -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yv

Re: [Tutor] tokenize row numbering

2005-05-02 Thread Andrei
above shows that numbering begins at 0, with the fourth line having number 3. So either I misunderstand the question, or the snippet is confusing. That being said, I can imagine counting lines from 1 because programming editors also tend to count from 1 instead of 0 and this way it

Re: [Tutor] Psyco (Joseph Quigley)

2005-05-04 Thread Andrei
than regular Python, it is still much > slower than C. Except in some amusing cases: http://mail.python.org/pipermail/python-list/2004-April/215272.html -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gu

Re: [Tutor] dicts&lists vs objects

2005-05-12 Thread Andrei
ut to have some benefits (it's possible to mix OO and procedural code). If a project runs into thousands of lines of code, it virtually always makes sense to bring OO into the picture. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python Resources

2005-05-13 Thread Andrei
o this mailing list and ask questions (though I do caution > them not to submit their homework simply to get a solution). I think people reading a magazine called "IT Pro" should be aware of such basic etiquette :). -- Yours, Andrei = Real contact info (decode with rot13)

Re: [Tutor] YATENJoe

2005-05-17 Thread Andrei
learn a bit more about Python's facilities before embarking on an ambitious project :) - you won't get very far without knowing how to use lists and dictionaries. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Opinions about this GIS script

2005-05-17 Thread Andrei
7;,indexfile.read(4))[0]" and similar lines. A file class which would wrap this stuff and offer a nice interface with methods like ReadInt, ReadDouble would clear it up a bit. - "Private function" in the comment of __newdemo. I'd remove it, since the double underscore already documents this. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] I know you will hate this but...

2005-05-17 Thread Andrei
should go around modifying code on its own in *any* way, even if it's spaces. Although, now that I think about it, a VCS might have an option of ignoring leading/trailing whitespace when doing diffs, such an option could bite when merging Python code. Yours, Andrei __

Re: [Tutor] YATENJoe

2005-05-17 Thread Andrei
at "How to think like a computer scientist in Python" (http://www.ibiblio.org/obp/thinkCSpy/). Chapters 8 and 10 discuss Lists and Dictionaries http://www.ibiblio.org/obp/thinkCSpy/chap08.htm http://www.ibiblio.org/obp/thinkCSpy/chap10.htm , but I'd recommend you rea

Re: [Tutor] I know you will hate this but...

2005-05-18 Thread Andrei
when a specific revision is requested. Sure you > hope it's the same as it was in the beginning but there's always a > chance for error. Yep. But the fact that only the indentation changed, sounds fishy. I'd rather expect editor settings to be at fault than the VCS. If you

Re: [Tutor] Password

2005-05-18 Thread Andrei
be decrypted without the password, even if the source code is available. -- Yours, Andrei = Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb gurer'f ab arrq gb PP. __

Re: [Tutor] While loop exercise

2005-05-22 Thread Andrei
or 2-person rooms and applies a discount if the reservation is on a day between monday and thursday. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Expression order problem

2005-05-26 Thread Andrei
t;> test5.var() Traceback (most recent call last): File "", line 1, in ? File "", line 4, in var NameError: global name 'dummy' is not defined >>> dummy = 234 >>> test5.var() 234 >>> test5().var() 234 Which soultion is right, depends on your needs. I'm tempted to say (3) is the best one, unless you really need that to be a class attribute. Tip: http://zephyrfalcon.org/labs/python_pitfalls.html Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] python problem

2005-05-26 Thread Andrei
couldn't convert to integer print 'Not a number' choice = 5 Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Planning a program with algorithm?

2005-05-30 Thread Andrei
all games exit If you go into more detail, you'll end up writing a long version of the Python code, which kind of defeats the purpose of pseudocode. > Any useful advice for algorithm would be appreciated. It's more important (at least for larger progams) to think about good design in

Re: [Tutor] Planning a program with algorithm?

2005-05-30 Thread Andrei
y get more comments, while easier portions get fewer comments - just as it should be. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Planning a program with algorithm?

2005-05-30 Thread Andrei
omething similar, this code would still not be quite high level, because shuffling the source, taking a slice and such are not built into those languages. In fact, in those languages you'd most likely choose a different approach at this level. Yours, Andrei _

Re: [Tutor] Planning a program with algorithm?

2005-05-31 Thread Andrei
ly in the directions which could be foreseen beforehand). Going from design-in-head straight to production code doesn't (at least for me) lead to the best of results in those respects, even though the code may work. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] samples

2005-06-23 Thread Andrei
e of loading all kinds of simple minigames. I don't know how far it is by now, but if you look in the pygame mailing list archives you should be able to find it. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] My first recursive function...

2005-07-28 Thread Andrei
if the function finds it has called itself too many times - helps against infinite recursion too. >>> def a(i): ... i += 1 ... if i < 500: ... a(i) >>> a(0) If you try the function above without the if condition, it will generate a Runt

Re: [Tutor] Custom metaclass?

2007-04-19 Thread Andrei
around all this metaclass safety by adding using this code: NoNewAttrs.__metaclass__.__setattr__ = type.__setattr__ NoNewAttrs.__setattr__ = object.__setattr__ nna.x = 5 print 'After reset: nna.x =', nna.x Run this and you'll see

Re: [Tutor] Calculator research

2007-06-02 Thread Andrei
Glade - you can design your interface in a point-and-click manner. You will need to learn a bit about wxPython in the process, but don't have to become an expert. -- Yours, Andrei = Mail address in header catches spam. Real contact info: ''.join([''.join(s) for s in

Re: [Tutor] Searching Sorted Lists

2005-08-20 Thread Andrei
n: http://en.wikipedia.org/wiki/Binary_search Yours, Andrei = Mail address in header catches spam. Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb gurer'f ab arrq gb PP. ___

Re: [Tutor] Strange "snippets" in Learning Python, 2nd ed.

2005-08-20 Thread Andrei
sition, swallows and just about anything else that seems weird can usually be tracked down to that same source. -- Yours, Andrei = Mail address in header catches spam. Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb

Re: [Tutor] Python DB

2005-09-22 Thread Andrei
looking up treatments/illnesses for a given patient (with the patient being the key in the database) or if the number of patients is quite low (hundreds). If however an important use is to do other types of searches too (e.g. find all patients with an age above X who use a drug Y) and you ha

Re: [Tutor] Remaking Vim in Python (was Python Editors)

2005-09-23 Thread Andrei
ave an editor in which to be productive, it's probably better to invest some time in learning to use one of the existing options. Whether it's Spe, Scite, Komodo, Vim, Emacs or whatever else suits you, is not very relevant. -- Yours, Andrei = Mail address in header catches sp

Re: [Tutor] Error checking - very basic question

2005-09-25 Thread Andrei
> I can't see a simple way around it (wood for the trees) How about using a "while True" loop that you break out of only when a correct value has been identified: while True: dau_version = raw_input('blabla') if dau_version in ("2.8",

Re: [Tutor] creating strings

2005-09-25 Thread Andrei
h of if-statements. if g is between X1 and Y1: result is Z1 else if g is between X2 and Y2: result is Z2 else if ... -- Yours, Andrei = Mail address in header catches spam. Real contact info: ''.join([''.join(s) for s in zip( "[EMAIL PROTECTED] pmfe!Pes ontuei

Re: [Tutor] Exception handling - syntaxerror?!

2005-09-25 Thread Andrei
important difference. You should terminate the try-except block (confirm with extra ENTER) before doing more stuff. -- Yours, Andrei = Mail address in header catches spam. Real contact info: ''.join([''.join(s) for s in zip( "[EMAIL PROTECTED] pmfe!Pes ontuei ulcp

Re: [Tutor] Exception handling - syntaxerror?!

2005-09-26 Thread Andrei
x27;, e.g. ">>> print 6; print 5" will work just fine. -- Yours, Andrei = Mail address in header catches spam. Real contact info: ''.join([''.join(s) for s in zip( "[EMAIL PROTECTED] pmfe!Pes ontuei ulc

Re: [Tutor] Tutor Digest, Vol 19, Issue 82

2005-09-27 Thread Andrei
ng at the top of the digest: 'When replying, please edit your Subject line so it is more specific than "Re: Contents of Tutor digest..."' -- Yours, Andrei = Mail address in header catches spam. Real contact info: ''.join([''.join(s) for s in

Re: [Tutor] Installing ActiveState Python vs2003

2005-09-29 Thread Andrei
ython, which seems to be what you got - one is a Python distro, the other is an extension of the VisualStudio IDE. Neither is a .Net implementation of Python, IronPython is (http://www.ironpython.com/). Yours, Andrei ___ Tutor maillist - Tutor@pyth

Re: [Tutor] Global var problem

2005-10-28 Thread Andrei
s for input and the return statement to output any necessary modifications, e.g.: def p(inp): output = inp + 1 print output return output if __name__ == '__main__': x = 5 x = p(x) It would be even better with a decent function name of course :). More i

Re: [Tutor] Recursion and List Comprehensions

2005-10-28 Thread Andrei
mutation retList.append(word) else: # Return a list of all permutations using all characters [ retList.extend( [ word[pos] + item for item in permute3(word[0:pos]+word[pos+1:len(word)]) ] ) for pos in range(len(wor

Re: [Tutor] Circular approach to a dictionary structure

2005-10-28 Thread Andrei
quires a single update, while the dictionary requires one new key-value pair and modifications in another two places in order to get it working correctly. -- Yours, Andrei = Mail address in header catches spam. Real contact info: ''.join([''.join(s) for s in

Re: [Tutor] Who called me?

2005-11-08 Thread Andrei
gt; def func(self): ... print self.__class__ >>> A.f = func >>> B.f = func >>> a, b = A(), B() >>> a.f(), b.f() -- Yours, Andrei = Mail address in header catches spam. Real contact info: ''.join([''.join(s) for s in zip( "[E

Re: [Tutor] First program -- would like comments and criticisms

2006-02-18 Thread Andrei
put a webbased interface onto it, or subclass it and make a glossary which can also do multiple language translations, or use a different storage backend, etc.). -- Yours, Andrei = Mail address in header catches spam. Real contact

Re: [Tutor] i have a question

2006-03-12 Thread Andrei
"Hello %s" % username else: print "Incorrect name or password!" Other environments (e.g. wxPython, PyGame or web interfaces) offer different ways of achieving the same results, but I presume you're really new to Python and not yet messing around with those. Yours, Andr

Re: [Tutor] Some questions about my yen-USD.py

2006-09-07 Thread Andrei
on "amount <= 0" and inform the user that a number larger than 0 is required. Here's a modified version: def getAmount(currency): while True: useramount = raw_input('Amount: ').lower().strip() if useramount in 'qx': return

Re: [Tutor] python & mysql question

2006-09-07 Thread Andrei
Patricia gmail.com> writes: > I have to store and retrieve text files from a database table and > the size of each file is about 500k. Can someone give me an idea > on how to do this? You might want to have a look at this: http://sourceforge.net/projects/mysql-python Yo

Re: [Tutor] Some questions about my yen-USD.py

2006-09-07 Thread Andrei
cript, this difference is of no consequence (that value is close enough to zero): >>> "%.2f" % (.1+.1+.1-.3) '0.00' Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Some questions about my yen-USD.py

2006-09-07 Thread Andrei
ith '%%'. E.g.: >>> "%%.%df" % 2 # the '%%' will be changed to '%' in the result '%.2f' >>> "%%.%df" % 4 '%.4f' >>> s1 = "%%.%df" % 2 >>> print s1, s1 % 3.41234 '%.2f', '3.41' >>> s2 = "%%.%df" % 4 >>> print s2, s2 % 3.41234 '%.4f', '3.4123' >>> ("%%.%df" % 2) % 3.23423 '3.23' Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Some questions about my yen-USD.py

2006-09-08 Thread Andrei
for function names is that they should contain a (well chosen) verb and an object. As always it ends up being a matter of personal taste. I for example might call that function insertSeparators or formatNumber, but other people might prefer longer names

Re: [Tutor] python for web developing

2006-09-14 Thread Andrei
Py, which is part of TurboGears) seems to have decent support for all kinds of Python things, but it's paid - if they allow a 1-month account, you could try it out for very little money over there. Yours, Andrei ___ Tutor maillist - Tutor@python.o

Re: [Tutor] Limitation of range() function in Walking problem

2006-09-16 Thread Andrei
rted locs:", locs maxrange = locs[0][:] # guaranteed to start with min for loc in locs[1:]: # loop over rest of locs if loc[0] <= maxrange[1]: maxrange[1] = loc[1] else: print " discontinuity found for", loc return None

Re: [Tutor] Lists in lists

2006-09-16 Thread Andrei
ll take item #0 in MyList and request its item #1. It's equivalent to saying MySubList = MyList[0] print MySubList[1] In an interactive session: >>> li = [[1,2], [3,4]] >>> li[0] [1, 2] >>> li[0][0] 1 >>> li[0][1] 2 >>> li[1][1] 4 Yours, Andr

Re: [Tutor] Question about startswith() and endswith() in 2.5

2006-09-25 Thread Andrei
are not specified. You could read it like "if the filename ends with .gif or .jpg or .tiff". In older Python versions, you could implement the same functionality as: if s.endswith('.gif') or s.endswith('.jpg') or s.endswith('.tiff') This is in co

Re: [Tutor] Efficient programming questions. Tuples vs Li sts; Custom Objects vs Lists.

2006-09-25 Thread Andrei
od on a certain object, without knowing what that object is - it needs to examine the object at runtime to determine if the method is available. The potential compiler would have to handle all of these cases, meaning you'd end up with... well, CPython. Typical compiler efforts in the past have limited the flexibility of the language. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] e-learning Python

2006-09-26 Thread Andrei
PA sapo.pt> writes: > Is there any site offering e-learning about Python? > > If not, the PSF should do it! If you mean if there are any online tutorials: lots of them. Here's a very large list: http://www.awaretek.com/tutorials.htm

Re: [Tutor] e-learning Python

2006-09-28 Thread Andrei
ewed by a teacher in a more classical approach. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Workaround for limitation in xrange()?

2006-10-10 Thread Andrei
ested), but it will take anything you throw at it as long as Python itself can handle it. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Evaluate my script?

2006-10-24 Thread Andrei
ing is potentially dangerous. Say I accidentally specify p=2atn. The program will calculate with 2 kPa, but I wouldn't know that. If instead it displayed its interpretation of my input by writing "p = 2 kPa" to the screen, I'd have a better chance of noticing. Alternatively

Re: [Tutor] OOP and Python.. a gentle remark

2006-10-25 Thread Andrei
ses very cumbersome to deal with, or trusting the programmer to do the right thing - thereby making it easier to stick his grubby little fingers in places where he shouldn't. Some people prefer the former, some the latter. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Of integers, relations and trees

2006-12-09 Thread Andrei
a child, otherwise they're unrelated. > I can't seem to rack my brains around a solution for this. Maybe it's > my tree-structure that is making this more complex than it should be? Hierarchies are easier if you look at them as families: it's easier to ask a parent how many children it has, than it is to ask one of the siblings if there is any sibling younger than it, then ask that younger sibling if it has any younger siblings, etc. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] class methods as argument

2007-02-10 Thread Andrei
_init__(self, x): self.x = x ... def dostuff(self, arg): ... print self.x ... print arg ... >>> def dostuff(obj, method): ... method(obj, 'blabla') ... >>> a = A(5) >>> dostuff(a, A.dostuff) 5 # this demonstate

  1   2   >