scru 909

I'm not sure I fully understand your questions, but the reason your addFirst does not work seems to be line 19:

Should be [icode]list.head = first[/icode] instead of [icode]list.head == first[/icode]

_neo_ commented: great! +1
scru 909
scru 909

[QUOTE=Toddh86;1192666]Thanks for clearing that up! How do I get the program to only get one word from the line in the text file?
With the example I gave earlier

Barry, Crocker, 17, 19, 30

Say I wanted a program to grab the surname (2nd word) from the list,
how would I achieve that?

Cheers[/QUOTE]

Assuming that a comma followed by a space separates each word, then you can use split:

[code=python]
words = open("myfile.txt").read().split(", ")
print words
[/code]

A bit more flexible, assuming just the comma:
[code=python]
words = open("myfile.txt").read().split(",")

At this point, each word in words may have a whitespace at the beginning.
You can strip them off in a for loop

stripped_words = []
for word in words:
stripped_words.append(word.lstrip())

print stripped_words
[/code]

Hang on a second. If this is csv file, then you can just use the [URL="http://docs.python.org/library/csv.html"]csv module[/URL].

scru 909

If you want to say "not equal to", use [icode]!=[/icode].

For cases where you mean not, use the [icode]not[/icode] keyword.

Examples:
[code=python]

"5" not in "12345"
False
not True
False
not False
True
[/code]

scru 909

No. It [B]may[/B] be possible with some sort of web page control, but that solution would be so convoluted that I don't even want to think about it.

Are you just trying to get syntax highlighting, or do you want pygments specifically? For the former, use wx.StyledTextCtrl.

scru 909

I'm not sure what you mean by "the best way to read from a text file." In what respect? Speed? Memory Consumption? Elegance?

The [icode]while len(line) != 0:[/icode] literally means "while the line is not an empty string" (Personally, I'd use the much cleaner [icode]while line:[/icode]. It means the same thing with strings). In this context, it means to execute the block until you reach the end of the file, at which point the line will be an empty string. Note that a blank line within the file is seen as [icode]"\n"[/icode] and not [icode]""[/icode], and as such would not be seen as the end of the file.

Edit: yeah the ! in != means not.

scru 909
scru 909

If I have any dependencies that require 2x, I use 2x. Otherwise I use 3.

scru 909

Nevermind. I contacted bitbucket and got the code.

scru 909 Posting Virtuoso

Does anybody know of any libraries or scripts or even code snippets that can generate HTML code from a diff or comparison of the contents of two files? I know of the HtmlDiff class in difflib, but the format it outputs is not the one I want (it puts both files side to side; I want something more like how it is seen here: [url]http://bitbucket.org/tjd.rodgers/codeback/changeset/f9bd5e5831d6/#chg-CodeBack.pyw[/url])

scru 909

If you're trying to get the current item in the QListWidget, this is trivial:
[code=python]
text = ''
cur = lw.currentItem()
if cur is not None:
text = cur.text()
[/code]

You code will have to check that text is not empty before doing anything with it.

Source: [url]http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qlistwidget.html[/url]

scru 909

[QUOTE=SoulMazer;1076370]Okay, well I've been looking for at least an hour now for some straight-forward python-xlib documentation, and I have been unable to find any. Luckily...I have quite the easy problem.

If somebody would be able to help me create a simple script that would say "Hello" every time the left mouse button is clicked, I have the rest of what I would like to do figured out

This is what I have so far, to no avail:
[code=python]#!/usr/bin/python

import Xlib
import Xlib.display

def main():
display = Xlib.display.Display()
root = display.screen().root
while True:
event = root.display.next_event()
if event:
print "Hello"

if name == "main":
main()[/code]
Thank you so much in advance.[/QUOTE]

This should help you out. It's written in C++, but the Xlib wrapper for python is very light so it shouldn't be hard to translate.

Have fun.

scru 909

Since we're using python, we could allow users to plug in routines to be called like regular tasks (we could support Python and C language routines). We could also support task chaining; i.e, call another task only when another is successful, possibly passing the out from one as input (and we could also offer ways to transform that output into suitable input).

Any of that made any sense?

scru 909

[QUOTE=Gribouillis;1069114]Ok, the repo is created, you can download the repo with the following command which creates a cronstalk directory. It's in lower case because google code forced me to do so. The repository is completely empty. Here is the [url=http://code.google.com/p/cronstalk/]project home[/url].
[code=text]
hg clone https://cronstalk.googlecode.com/hg/ cronstalk
[/code]
As soon as possible I'll try to figure out how you can commit changes to the repo.[/QUOTE]

Add us under people.

scru 909

I suppose you can create the repo.

scru 909

Okay. So should we target 2.6 with compatibility hacks for 2.5 or just go for 2.5?

scru 909

[QUOTE=ShadyTyrant;1069013]Ok the e-mail thing is fine but is may be easier to post decisions on the thread. That way we can see all reply's. Also as some one mentioned it will give others insight on how development teams work.

I agree on the MIT license. As far as project hosting what ever one you would rather use is fine with me. They are both reliable hosts.

Here are a few suggestions for names:
TimeSeries (Gribouillis)
TimedTasks
CronIt

Scru what OS are you developing on?[/QUOTE]

I'm using Windows. Speaking of, what platforms are we targeting? Anything that Python would run on?

scru 909

If you guys know how to use vcs, we can use Google Code. No need to spam the thread with so much code.

scru 909

Hey I think I'm pretty good with Python, would love to be shown otherwise.

Sign me up (weekends only)!

scru 909

did you install the win32all package?

scru 909

[code=python]lines = text.split("\n")
for i, l in enumerate(lines):
print "line %d: %s" %(i + 1, l)
[/code]

scru 909

Could you give me an example? I think I have an idea what you mean, but I'm not sure.

scru 909

If you want your scripts to be portable you do.

scru 909

[QUOTE=mn_kthompson;1047514]I guess it depends on what you mean by simplify. If you mean fewer lines of code, then yeah there are ways to simplify it.

If you mean make the code more readable so that the next person who has to maintain your code will be able to, then probably not. The code you've written is easy to follow, well commented, and doesn't make use of any obscure libraries or tricks. Your variable names make sense and the whole thing is easy on my eyes. Personally, I would be proud of this code. You might be able to shave a few microseconds here or there by doing something, but if it comes at the expense of readability then it isn't worth it.[/QUOTE]

Here here!

That said, I would suggest you use [icode]if x in dict.keys()[/icode] rather than [icode]if dict.has_key()[/icode] since the latter is deprecated in later versions of python (it's never too early to start preparing yourself for the switch, even if you don't intend to anytime soon). Besides, it's slightly closer to what you would actually say in English, which makes it slightly easier to follow. Slightly.

scru 909

It's important to note that this language doesn't seem to be designed for a Python programmer craving more speed. Rather it seems geared at C++ programmers who feel they could benefit from some specific features which can be found in languages like Python, hence the phrase "a cross between C++ and Python" can be a bit misleading.

scru 909

Great tutorial, I have some comments.

In python re, you can omit the ^ and $ from your regular expression and use [icode]re.match[/icode] to match the string from start to finish against the expression, as long as you don't require newlines to be taken into account. This way you can use the same pattern to search within the string, or to match the entire string.

Also, if you need to use a pattern more that once, you may as well compile the pattern into a regular expression object.

[code=python]
email = 'bogusemail123@sillymail.com'

pattern = r"[A-Za-z0-9.]+@[A-Za-z0-9.]+.com"
rexp = re.compile(pattern)

print not not rexp.match(email)

True

print not not rexp.match("@sillymail.com")

False

print not not rexp.match("bogusemail123@sillymail")

False

[/code]

scru 909

When it comes to writing parsers, I tend not to write parsers at all and rely on parser generators like Wisent.

Anyway, care to show us the code of what you'll already doing?

scru 909 Posting Virtuoso

I have a 1 year old dv9920us laptop that is refusing to boot into Windows Vista. The Vista "loading screen" appears, but the marquee doesn't and the laptop is perpetually stuck in this state. I was able to boot into live Linux and access my hard drive form there, so i am unsure as to what exactly the problem (Windows or hardware)

scru 909

Guess I know whom [I]you [/I]voted for.

scru 909

This isn't really a problem, but if it were, it would be quite a nice one to have.