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

Not really sure what exactly you're trying to do...

scru 909

I say just ignore the thing until it crawls back under the bridge. It cannot be reasoned with.

Grn Xtrm commented: Nice troll analogy. +0
majestic0110 commented: Too true! +0
scru 909

Okay, I didn't read much of what was said (I tend not to pay much attention to fanboys). But anybody who says things like "Anyone who has a good understanding of operating systems in addition to Windows, generally won't use Windows" and "Linux driver support is far superior to Windows" as arguments for Linux should be instantly dismissed. It's not to say that there aren't quite a few very good arguments for Linux; they're just not these.

Why would the average user want to have an understanding of how operating systems work? Most people just want to get on a computer, use it, and get off. As far as I know, this is how it works with Windows (and Mac). It's possible with some tame versions of Linux too. Nobody wants to know what happening behind the scenes to allow them to do that.

Linux driver support is a far cry from superior. I don't understand how a rational person can come to the conclusion that it is. Do you realize that most Linux drivers are practically hacks because most hardware manufacturers don't bother to support linux (so the community has to do it themselves) and the ones that do write drivers so horrible that they break your system (nvidia and x server, anyone?)?

I don't get how Linux fanatics constantly complain about FUD when they are the worst perpetrators.

William Hemsworth commented: Well said. +0
jbennet commented: agree +0
scru 909

[QUOTE=R1pperZ;1006279]Well said why do we trouble ourselves with such incompetant software?

Well the fact that you have to face is the majority of the computing public are tech lazy, they want things to work with little to no action on their part and look good doing it. Plus most people assume that Windows is the best OS out there and that Mac is the only alternative, not to mention the fact that all pre-built PC's come installed with windows and most people believe if it works don't screw with it.

I've only recently decided to go beyond just understanding the basics and learning hardware specs and customized software. I think I am [B]finnaly[/B] ready to go with linux, what do I have to [B]loose[/B]? My system is sitting here now full of countless bugs, malware apps and worthless software...[/QUOTE]

I can tell already that you won't have much luck with Linux.

majestic0110 commented: Lol +0
Will Gresham commented: :) +0
scru 909

[QUOTE=foosion;984309]One byte is a number, two bytes is a string of bytes. One str element is a string, two string elements is a string. If you accept that, it all makes sense. However, it seems to have changed from 2.6 to 3.1.

The reason I got into this was trying to port a 2.6 app to 3.1. The code reads some bytes from a file, then examines the bytes.

[code]f = open(filename, 'rb')
data =
if data[0:2] == '\xFF\xD8':
if data[2] == '\xFF' and data[6:10] == 'Exif':

Note that both single bytes and the sequence of bytes are treated the same, and that they don't require any 'casting' for the comparisons.

This works in 2.6, but fails in 3.1. 3.1 requires
[code]if data[0:2] == b'\xFF\xD8':
if data[2] == ord('\xFF') and data[6:10] == b'Exif':

Note that the single byte is treated differently than the sequence, and that we need to add 'b' and 'ord'.

As an aside, haven't we eliminated longs in 3.1, so that all numbers are of type int?[/QUOTE]

bytes, as they exist in Python 3.1 are conceptually new to Python (starting with version 3). This isn't to say that 8-bit strings didn't exist before in the form of regular text strings. Note the distinction, each element in a 8-bit python 2.x string (str) is treated as a character, not a byte, yielding the same slicing and indexing behavior as str in Python 3.1. Note that the bytes type in Python 2.6 is a synonym for ...

vegaseat commented: Thanks for the help +14
scru 909

[QUOTE=foosion;983956]Is this in the documentation somewhere?

[code]>>> a = b'\x01\x02'

<class 'int'>
<class 'bytes'>
a = '\x01\x02'
<class 'str'>
<class 'str'>[/code]

Note that in the byte string version, a[0] and a[0:1] return different types, while in the regular string version, both return the same type. Why does it make sense to treat the two cases differently?

I would have expected python to be more consistent.

Here's a similar example:
[code]>>> s = "hello"

<class 'str'>
b = s.encode()
<class 'bytes'>

I happen to think this behavior is consistent (with indexing and slicing rules).

Here's why it makes sense:

bytes and str are [B]not[/B] the same. They aren't even conceptually the same.

A bytes (byte string) is a sequence of bytes (I assume you know what a byte is, and that it isn't a "character"). It is data, [B]not text[/B]. A string on the other hand is a sequence of [B]characters[/B] and is text.

As I mentioned earlier, indexing a byte string gives you a byte (it's a [B]sequence of bytes[/B], so this makes perfect sense). Since a byte is a numeric type (and [B]not a character[/B]) what you get is a number (long). Slicing a sequence gives you the portion of the sequence from a to (but not including) b as a new sequence. Note that slicing a sequence always gives a sequence. Why? ...

scru 909

Look, not to be harsh or anything, but given you previous posts I think you would be better off reading a book or a wiki or even just a tutorial on Python OOP and maybe Python in general. Really.

vegaseat commented: glad you said it! +14
scru 909

[QUOTE=NicAx64;978835]come on man ! computers are always fine man , after you get a one
then you need another one , after you get two you need another one.... It's a brain acceleration tool man, you will never satisfy no matter how many computers you own. 1,2,3.....100...until infinity.[/QUOTE]
Definition of "own"[/URL]
[URL=""]Defintion of "use"[/URL]

mvmalderen commented: I like your new avatar. Way better than your previous one! +21
scru 909

[QUOTE=Lingson;955374]ugh.. the solution was so easy? lol

one more question then:
is it safe to say that everytime i want to convert bytearrays to string i just need to use the .decode('utf8')?...some other stuff...[/QUOTE]

No, please don't do that.

That is okay if the page you are reading is encoded in ascii or utf-8. But if it is encoded in latin-1 (a fairly common encoding in its own right), you can run into trouble with non-ascii characters (like é for example)). And this is just for sites in languages based on latin script.

What you have to do is get the encoding from the server. The web server sends out the encoding that it uses* in the http header. The general idea is that the pages it serves would use that encoding.

  • If only it were that simple. Sometimes the pages on the web server itself are encoded using a different encoding than what the web server is set to report (blame it on lazy, inconsistent webmasters?) Ideally, these pages have their encoding specified in their HTML headers.

Oh right, you were looking for a solution? I generally start decoding with the encoding that the http header specifies, but if the page's html header specifies a different encoding, I start over again with that new encoding. And if all else fails, either fall back to utf8 or refuse to decode all together. I know it sounds overly complicated (it probably is) but it's worth not having your application crash ...

Nick Evan commented: excellent suggestion +25
scru 909


Nick Evan commented: agree +23
scru 909

Damn, you're ugly. The both of you.

sknake commented: i knew it was coming :P +4
jbennet commented: im offended ;( -7
MosaicFuneral commented: True dat. +6
Ancient Dragon commented: Agree :) +36
scru 909

It's a little sad that some people are still holding onto the idea that Vista is what XP was. ME, perhaps, but not XP. Even Microsoft sees Vista as a failure. Sure Vista introduces some nice things, but as an entire package it is shoddy work.

And as evidenced by the coming release of Windows 7, Vista is definitely not the future. Advising someone to upgrade to Vista now, only to be dissatisfied and upgrade again (or just ditch the platform altogether, understandably) is just plain irresponsible--not to mention it reeks fanboyism.

jephthah commented: QFT +14
scru 909

Joking aside, there really is no point to insisting on the use of int main as opposed to void main.

void main()
printf("hello world!\n");

is just as valid a program as
int main()
printf("hello world!\n");
return 0;

if you don't sacrifice offerings to the writers of the C standard. That return 0; is wasted effort.

If for some reason an error occurs in your program (real programmers design their programs in such a way that fatal errors never occur) and you need to indicate, that's exactly what stderr is for.

sknake commented: excellent advice! +4
scru 909 Posting Virtuoso

It's time to get that stick out of your butt and start using it. So what if the standard says so? You're only writing code for Windows anyway (and if you aren't, the chances that someone else is even going to need to use your program are really slim) so who cares if you aren't returning anything meaningful? Alright, so maybe a few purists will pop some blood vessels somewhere in their moms' basements, but so what?

"Because I feel like it" is as valid a reason as "because the standard says so".

jephthah commented: scru brings the LOLs. +13
scru 909

Well, I'm not Dan, but here's a little hack adapted from [url][/url] for Python. It's only two lines of code!
To open:
import ctypes
ctypes.windll.winmm.mciSendStringW("set cdaudio door open", None, 0, None)

To close:
import ctypes
ctypes.windll.winmm.mciSendStringW("set cdaudio door closed", None, 0, None)

Note, if you're using python 2.x, either change mciSendStringW to mciSendStringA, or change the first argument to a unicode string (recommended) by prefixing it with a lowercase u.

vegaseat commented: nice Windows hack +12
scru 909

That's one reason [B]not[/B] to sign.

mvmalderen commented: Agreed :) +17
William Hemsworth commented: haha :D +13
scru 909

Kim Jong-il: It's time to launch an offensive on those imbeciles. Something that will make them squirm and rue the day that they did that one thing to piss me off, bringing their societies to a [URL=""]general disarray[/URL]! Ideas?

New Intern: Let's bring their websites down for a couple hours. That'll show 'em!

Kim Jong-il: I like the way you think.

Nick Evan commented: Haha :D that's how it works +21
scru 909

Give Google control of my desktop? I'm too paranoid for that.

shadwickman commented: Google knows EVERYTHING about you :P +4
scru 909

Oh, I have no favorite. I just came to point and laugh at Naruto fans.

maydhyam commented: Heyyyyy....that's not nice....... :( +0
jephthah commented: I'm Jephthah, and I approve of this post. +11
<M/> commented: lol +0
scru 909

Aw hell nah. I'm not gonna debug that for you. But, is this supposed to be a game? Why isn't it interactive? If it is, how do I play it? I actually love this silly game.

MK12 commented: quick reply +1
scru 909

[QUOTE=Sky Diploma;888305]So people, Lets just stick to the movies and not go into hatred.[/QUOTE]
I hate you.

Sky Diploma commented: Lol !! +3
jephthah commented: haha +10
scru 909


import urllib
import os
import time


def shutdown():
os.system('shutdown -s')

for item in file:
if test=='shutdown_now':

sravan953 commented: Great +1
scru 909

[QUOTE=hcwebb;883748][B]I've been putting off installing XP[/B], but, as you say, 2k support is waning.

Is XP Pro reliable enough to depend on? Any ongoing complaints?

Windows 7, eh? Will it be a thorn initially, as Windows updates all tend to be, or will it be a pleasure to see, as OS-X updates are?

Or shall we wait for version 7.1 as we did v3.1?[/QUOTE]


Something to note though, Windows 7 is definitely not faster than XP (not comparable to XP speeds either). It won't run well on XP class hardware. That said, if you still have XP class hardware and don't want to upgrade it, you should be seriously considering running a non-Windows OS at this point.

jephthah commented: ya i know, rite? +10
scru 909

If you want to just find out if one string is contained inside another:
[code=python] strvalue1 in strvalue2[/code]

If you want to find out how many occurrences of one string there are in another:
[code=python]num = strvalue.count(strvalue2)[/code]

If you want to find the index of the first occurrence of one string in another:
[code=python]ind = strvalue1.find(strvalue2)[/code]

vegaseat commented: nice help +12
scru 909

[QUOTE]Cleverbot: Did you find me on Google?

User: No.

Cleverbot: Did you find your brother.

User: My brother was never lost.

Cleverbot: Did he die?

User: No, my brothers are alive...

Cleverbot: My brother is named Jushiro.

User: What's he like?

Cleverbot: She not he.

User: Your brother is a she? How?

Cleverbot: No.

User: You're not very smart.

Cleverbot: And you?

User: I'm smart enough.

Cleverbot: It seem you are very proud of yourself!

User: seems.

Cleverbot: Are you?

User: I'm not conceited, if that is what you are asking.

Cleverbot: Are you a fascist?

User: No. Why would you ask me that?

Cleverbot: It interests me to know what you are conscious of?

Cleverbot (To myself): I don't know? Does it?

User: Bye.

Cleverbot: Why do you go to the forest?[/QUOTE]

iamthwee commented: priceless +21
scru 909

For those not knowing how to use IRC, here is a quick recipe on how to join the daniweb channel.

You will need:
Mozilla Firefox web browser


  1. Install that chatzilla add-on from here: [url][/url] (search for the button that says "add to firefox" and press it. A dialog should appear, on which you should press the "Install" button). When prompted, restart the browser.

  2. Start the chatzilla application: From your Mozilla Firefox Tools menu, choose Chatzilla.

  3. When the chatzilla window appears, type the following command into the text box and press enter: [code]/server[/code]

  4. Once chatzilla successfully connects to the daniweb irc server (when the progress bar stops moving), you need to join the daniweb channel, using this command: [code]/join #daniweb[/code]

  5. If you would like to change you nickname, use this command: [code]/nick YourNickName[/code]

EDIT: steps 3-5 can be applied to any irc client; I just used chatzilla for this recipe because it's a quick add-on to Mozilla Firefox, which a lot of people already have.

Ancient Dragon commented: perfect :) +36
Sulley's Boo commented: arigato =') +6
scru 909

I'm afraid I have to retract my original opinion about this film.

jephthah commented: takes a strong man to admit he was wrong :P +9
scru 909

The best way I think is to get a solid foundation in Python 2. That and read up a bit on unicode. Once done, you can just read the "What's new in python 3" page (Google it) and learn everything there is to know about using python 3.

jlm699 commented: Absolutely, +1 +4
scru 909

[QUOTE=Ancient Dragon;867948]I have a good friend I've known for 20 years who is from India and I still can't pronounce is name correctly! [/QUOTE]
Dude, you really should learn to pronounce his name right.

Sulley's Boo commented: :D +6