Re: [Tutor] When am I ever going to use this?

2006-08-01 Thread Jordan Greenberg
r you. Why implement a linked list, when we already have lists? Then Queues and Stacks are trivial to implement once you've got lists. If you're interested in learning more about data structures and their uses, this looks like a good reference: ht

Re: [Tutor] (*args, **kwargs)

2006-08-04 Thread Jordan Greenberg
27;, 'email': '[EMAIL PROTECTED]'} Key: name Data: jordan Key: email Data: [EMAIL PROTECTED] So, to summarize, *args and **kwargs are basically there so you can build your functions so that they can accept a variable number of arguments. We had a thread about this

Re: [Tutor] Python for basic web-testing

2006-08-06 Thread Jordan Greenberg
Hans Dushanthakumar wrote: > Hi, >How do I use python for basic web-tasks like inputting data or > clicking buttons on web-pages. For eg, how do I enter my username and > password and click on the "OK" button on the yahoo mail page? > I had a look at the webbrowser module documentation > (http:

Re: [Tutor] quick OO pointer

2006-08-07 Thread Jordan Greenberg
something_to_log() just like it was defined in that file. Example: #file: test1.py def spam(): print "Spam, eggs, and toast" #file: myscript.py from test1 import spam spam() #prints "Spam, eggs, and toast" Hope this helps! -Jordan Greenberg ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Rock, Paper, Scissors

2006-08-07 Thread Jordan Greenberg
issors That'll take care of the basics for ya. Later you could try and keep frequency counts over a bunch of trials, see if the human has a preference, and then weight your response appropriately to try and beat them ;) -Jordan Greenberg ___ Tuto

Re: [Tutor] foreach loops

2006-09-11 Thread Jordan Greenberg
Christopher Spears wrote: > Hmmm...Perl is probably a bad example. My apologies. > I was thinking more along the lines of this: > > A C++ for loop: > > #include > > using std::cout; > > int main() { > > for (int i = 0; i < 10; i++) { > cout << i << "\n"; > }

Re: [Tutor] Overloading the assignment operator in a class

2006-09-20 Thread Jordan Greenberg
bles as containers. That thinking isn't valid in Python. In Python, what you'd think of as 'variables' are just names for objects. (If you know C++, think pointers, sort of. myDie isn't the Die Object, its just a reference as to where the object is. Assigning to a pointer do

Re: [Tutor] Overloading the assignment operator in a class

2006-09-20 Thread Jordan Greenberg
return self.val, other In [2]: test=coerceTest(5) In [3]: test Out[3]: <__main__.coerceTest instance at 0x00E29620> In [4]: result=test+10 In [5]: result Out[5]: 15 In [6]: test=5 In [7]: test Out[7]: 5 (I could've written a test to show that __coerce__ is only called when n

Re: [Tutor] Trying to extract the last line of a text file

2006-10-19 Thread Jordan Greenberg
le object as a parameter, but theres no object left to pass it. HTH. -Jordan Greenberg ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] hardware specs from python on OSX

2006-11-08 Thread Jordan Greenberg
Yi Qiang wrote: > Hi, > I am trying to get some basic information about the computer's > hardware specs in OSX in python. In linux I can get most of what I > need from the /proc filesystem. Is there an equivalent in OSX? If > not, where else can I get information about the system from? I need >

[Tutor] Test

2006-11-28 Thread Jordan Greenberg
ROTECTED]) so my messages will come from there from now on. Sorry again for the test, Jordan Greenberg ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Best Known Method for Filtering redundant list items.

2006-11-30 Thread Jordan Greenberg
Chris Hengge wrote: > Anyone point me to something more efficient then > > for item in list1: > if item not in list2: > list2.append() > > This just seems to take a bit a time when there are thousands or dozens of > thousands of records just to filter out the dozen or so copies.. >

Re: [Tutor] Getting the directory the program is in

2006-12-11 Thread Jordan Greenberg
Toon Pieton wrote: > Hey friedly users! > > I was wondering: how can I get the directory the program is in? For example > "C:\Python Programs\Calculator\". > > Thanks in advance for reading, > Toon Pieton > Slightly hackish and nasty, but seems to do the trick. Someone'll probably suggest a bet

Re: [Tutor] Getting the directory the program is in

2006-12-11 Thread Jordan Greenberg
est.py test.py [EMAIL PROTECTED]:~$ cd / [EMAIL PROTECTED]:/$ python test.py /home/jordan/test.py [EMAIL PROTECTED]:/$ So, if you _ALWAYS_ need an absolute path, just using sys.argv[0] might not work. Jordan Greenberg ___ Tutor maillist - Tutor@python.or

Re: [Tutor] Yet another list comprehension question

2007-03-02 Thread Jordan Greenberg
Smith, Jeff wrote: > I find a common thing to do is > > l = list() > for i in some-iterator: > if somefum(i) != list: > l.append(somefun(i)) How about using the same condition you do in the if? Like: l=[somefun(i) for i in some-iterator if not type(somefun(i)) is list] HTH Jordan _

Re: [Tutor] Addressing a variable whose name is the value of a string

2007-04-09 Thread Jordan Greenberg
Andreas Pfrengle wrote: > Bob Gailer wrote: > >> Andreas Pfrengle wrote: >> >>> Hello, >>> >>> I want to change the value of a variable whose name I don't know, but >>> this name is stored as a string in another variable, like: >>> >>> x = 1 >>> var = 'x' >>> >>> Now I want to change the value of

Re: [Tutor] Python Programming Tools

2008-04-14 Thread Jordan Greenberg
complete IDE solution goes, PyDev for the Eclipse platform is pretty popular. If you're willing to spend some $$$, then PyDev Extensions (also for Eclipse) are good, or ActiveState's Komodo IDE. They seem to be the gold standard. -Jordan Greenberg _

Re: [Tutor] dollarize.py

2008-06-21 Thread Jordan Greenberg
Martin Walsh wrote: > def addcommas(f): > """ > This amounts to reversing everything left > of the decimal, grouping by 3s, joining > with commas, reversing and reassembling. > """ > # assumes type(f) == float > left, right = ('%0.2f' % f).split('.') > rleft = [left[::-1][i:i+3] fo

Re: [Tutor] Alter print action for objects

2008-07-23 Thread Jordan Greenberg
Shrutarshi Basu wrote: I'm working on a graph class to become more familiar with graphs in general. I'd like to be able to do something like 'print gr' and get something intelligible like a list of vertices. But using print on a Graph class instance simply returns Is there someway I can change