Posts
 
Reputation
Joined
Last Seen
Ranked #1K
Strength to Increase Rep
+7
Strength to Decrease Rep
-1
91% Quality Score
Upvotes Received
35
Posts with Upvotes
32
Upvoting Members
21
Downvotes Received
3
Posts with Downvotes
3
Downvoting Members
2
7 Commented Posts
~361.33K People Reached
About Me

I love Python!
I often play with D and C#.

Interests
School Biology Chemistry
PC Specs
Windows 7 OpenSUSE Ubuntu Netbook Edition
Favorite Tags

226 Posted Topics

Member Avatar for vegaseat

Here's a really evil Hello World program. You see, in Python, type(type)==type, so with that in mind, Classes are a type of type, which means that they inherit from type. So really, you can actually define a class by initiating a type of it, and then defining a classDict for …

Member Avatar for vegaseat
23
34K
Member Avatar for vegaseat

Here is [B]code[/B] for a [B]GUI[/B] program in [B]IronPython[/B], which is a [B]cross-platform[/B] (and of course cross-browser) implementation of CPython that has the exact same syntax. With IronPython you can use .NET with Python. This is [B]not[/B] a question. It's a code snippet for a GUI program. Pretty neat alternative …

Member Avatar for vegaseat
9
45K
Member Avatar for Taqwasarwar

Wouldn't be something like this? : [CODE] def main(): fname = raw_input ("Enter filename:") infile = open(fname,"r") data = infile.readlines() infile.close() items = len(data) print items, "number of items." main() [/CODE] You should add a try:/except: because the filename the user might be trying might not exist.

Member Avatar for vegaseat
0
311
Member Avatar for loken

C++ is a big thing to learn. It's really big. If you like Python (I'm a huge fan), you can use panda3d, which in my opinion is the simplest option, especially if you have a background in Python.

Member Avatar for cherqeza
0
1K
Member Avatar for mappersas
Member Avatar for Peter_21
0
6K
Member Avatar for lionaneesh

[QUOTE=tonyjv;1252311]In math.sqrt the math is module and sqrt is function. Nothing to do with objects.[/QUOTE] Well, not exactly [I]nothing[/I] to do with objects, if you realize that functions are in fact objects. But you are right, math is the module. Overall, very good tutorial on the basics of classes and …

Member Avatar for mail2sanjay
1
879
Member Avatar for vegaseat
Member Avatar for Tcll

I have some comments on your code. [CODE]import struct as S import Blender def HexToDec(n): #return float(S.unpack("<h", S.pack("<H", int((n.encode('hex')), 16)))[0]) #jcao219: please keep lines short, so it is readable nhex = int(n.encode('hex'), 16) packed = S.pack("<H", nhex) unpacked = S.unpack("<h", packed)[0] return float(unpacked) def readvert(v): #jcao219:where do you use this …

Member Avatar for Tcll
0
2K
Member Avatar for jeezcak3++

I was able to compile it with IronPython's compiler, so I can give you that, if you don't mind it running on .NET of course.

Member Avatar for vegaseat
0
627
Member Avatar for Tcll

[QUOTE=tonyjv;1296859]Could be that that module you want would work with IronPython or what you say IronPython gurus? Or the program could be complied to library (dll in Windows) and used as Python library with [URL="http://docs.python.org/library/ctypes.html"]ctypes[/URL]. Or you could see if [URL="http://code.google.com/p/shedskin/"]shedskin[/URL] could manage to turn all your code to C++ …

Member Avatar for JoshuaBurleson
0
2K
Member Avatar for tzho11

You can use WolframAlpha for graphing. I'm not sure what you want your program to do.

Member Avatar for JoshuaBurleson
0
154
Member Avatar for vegaseat

This method is great for basic cryptography in Python, however advanced and secure encryptions such as AES offer the best degree of security. For those of you interested in that, PyCrypto is for you.

Member Avatar for TrustyTony
3
7K
Member Avatar for TrustyTony

Well, if you want to be able to do this: [icode]for i in numberstack[/icode], you have to write the stack like this: [code] class Stack: """doc omitted""" def __init__(self,size): self.data = [None]*size self.size = 0 def push(self,item): self.data[self.size] = item self.size = self.size + 1 def pop(self): self.size = self.size …

Member Avatar for TrustyTony
0
857
Member Avatar for reanopp

There really is no fool-proof way, for any application written in any language. For C#, someone could maybe use Reflector and then see what creative registration processes you have written, unless if you obfuscate the code, which only makes it harder, never fool-proof. Good luck.

Member Avatar for Momerath
0
255
Member Avatar for singlem1905
Re: help

First of all don't use "globals" or "locals" as your identifiers, they are built-in functions. One possibility to fix this is to do this: [CODE]#execfile('comp1.py') def exefi(name, globalsmap=None, localsmap=None): if localsmap or globalsmap: exec compile(open(name).read(), name, 'exec') in globalsmap, localsmap else: exec compile(open(name).read(), name, 'exec') in globals() exefi('comp1.py')[/CODE] Another is …

Member Avatar for singlem1905
0
119
Member Avatar for Muro29

You could do that in Python, but since you are beginning Python, why not just use a service such as OpenDNS (which would be much easier to set up), instead of trying to deal with sockets, etc?

Member Avatar for jcao219
0
104
Member Avatar for techie929
Member Avatar for roboguy

[code]for file in [f for f in files if f.endswith(".html" or ".htm" or ".txt")]:[/code] is equal to [code]for file in [f for f in files if f.endswith(False)]:[/code] Don't use "file" as a variable name (identifier) since it's builtin. Escape [icode]"C:\New Folder"[/icode] as [icode]"C:\\New Folder"[/icode] or add an "r" before the …

Member Avatar for TrustyTony
0
260
Member Avatar for KrazyKitsune
Member Avatar for Sirovica

Lua has a really small standard library. Also, I think it's used a lot as a game scripting language.

Member Avatar for jcao219
0
72
Member Avatar for Ultralisk

[CODE]with open("scores.dat") as fileIn: for line in fileIn: if line: parse(line)[/CODE] (Something like that, I'm not sure if I wrote that correctly. I haven't been doing much Python lately.)

Member Avatar for TrustyTony
0
128
Member Avatar for KrazyKitsune

For windows you can use the msvcrt module: [CODE]import msvcrt import sys time_is_up = False #use threads to modify this userinput = "" while True: if msvcrt.kbhit(): ch = msvcrt.getch() if ch != "\r" and not time_is_up: userinput += ch sys.stdout.write(ch) else: break[/CODE]

Member Avatar for wikirifi
0
4K
Member Avatar for lionaneesh

One thing you have to be careful of is this tricky stumbling point (which arises because Python's lists are mutable): [CODE]>>> a = [[None]*3]*3 >>> a [[None, None, None], [None, None, None], [None, None, None]] >>> a[0].append("Hello") >>> a [[None, None, None, 'Hello'], [None, None, None, 'Hello'], [None, None, None, …

Member Avatar for redyugi
1
3K
Member Avatar for err1100

It may be easier to understand when you take comprehensions out. [CODE]def myfunc(x): ret = [] for i in range(2**len(x)): res = [] for j, y in enumerate(x): if (i >> j) & 1: res.append(y) ret.append(res) return ret[/CODE]

Member Avatar for jcao219
0
133
Member Avatar for anurag.kyal

I thought os.kill didn't work on Windows... [URL="http://docs.python.org/faq/windows.html#how-do-i-emulate-os-kill-in-windows"]http://docs.python.org/faq/windows.html#how-do-i-emulate-os-kill-in-windows[/URL] I see it now works on 2.7 and 3.2. I guess you are on linux.

Member Avatar for jcao219
0
159
Member Avatar for j3nny

[QUOTE=Gribouillis;1296241]0xfe is not the hex of -2, it is the hex of 256 - 2. You can use [code=python] >>> hex(-2 % 256) '0xfe' >>> hex(256 - 2) '0xfe' [/code][/QUOTE] Actually, it is for byte. If I can remember correctly, Windows, -2 is: [INDENT]Qword (long) = 0xFFFFFFFFFFFFFFFE Dword (int) = …

Member Avatar for jcao219
0
97
Member Avatar for abcdr

[QUOTE=tonyjv;1291565]Maybe the poster liked to have list containing integer length instead of the element for every element of the list. Then for line 5 use statement to return list of counts. What happens or is supposed to happen if the elements are numbers? Maybe len(str(element)) is better to add to …

Member Avatar for jcao219
0
101
Member Avatar for personx1212

No, you have to save it to a temp file. You can't expect software to be able to read your program's memory.

Member Avatar for personx1212
0
80
Member Avatar for Tommymac501
Member Avatar for jrthom444

Well, at first I thought what you want to do would require the traceback module. Now that I think about it, I think you use id. [CODE]def get_var_name(arg): for x in globals(): if id(globals()[x]) == id(arg): return x return[/CODE]

Member Avatar for jcao219
0
220
Member Avatar for bpatt22

Should be this: [CODE]d1 = dict() d1[0] = 1 d1[1] = 8 d1[2] = 8 maxValue = max(d1.values()) #<-- max of values print [key for key in d1 if d1[key]==maxValue][/CODE]

Member Avatar for TrustyTony
0
8K
Member Avatar for parijat24

I see you are working with Drosophila genetics. I'm not sure what you are trying to do.. can you explain it further?

Member Avatar for jcao219
0
198
Member Avatar for job2
Member Avatar for SoulMazer

I think the server processing speed would determine much of that. Also the speed of you LAN network, which you can test with LAN Speed Test [URL="http://www.totusoft.com/downloads.html"]http://www.totusoft.com/downloads.html[/URL]

Member Avatar for ultimatebuster
0
140
Member Avatar for ultimatebuster

[QUOTE=ultimatebuster;1278469]I'm kind of confused over the iterator object/concept and the yield statement and its usage. According to my understanding, all the python sequence are iterators, as they don't need the classic [icode=java]for (int i=0; i<list.length; i++)[/icode] to iterate through lists/arrays. Am I correct over this? Am I missing anything? Also …

Member Avatar for ultimatebuster
0
101
Member Avatar for prashanth s j
Member Avatar for TrustyTony
0
102
Member Avatar for Tommymac501

That indicates that the .csv file has it in scientific notation. No string-number conversions exist there. also this code [icode]L = ''[/icode] is useless. L is not "declared" as a string. Python doesn't do that. If L is first a string, it doesn't mean it will always be a string. …

Member Avatar for Tommymac501
0
2K
Member Avatar for jcao219

This is not my code! Taken from [URL="http://stackoverflow.com/questions/3230978/code-golf-four-is-magic/3231355#3231355"]this SO post[/URL]. You can use this to get the number of letters in the English representation of an integer, from 0 to 99. So for example 5 (five) is [icode]len("five")[/icode] which is 4.

Member Avatar for TrustyTony
0
176
Member Avatar for Simes

[QUOTE=tonyjv;1274972]You did not get rid of those un-Pythonic getters and setters.[/QUOTE] Yea, it would be doing us a favor if you removed them. They are quite painful to my eyes.

Member Avatar for Simes
0
533
Member Avatar for wolfeater017

[QUOTE=wolfeater017;1273575]cx-freeze 3.1 will work with python 3.0 right[/QUOTE] It will surely work with the latest version - Python 3.1.2

Member Avatar for Beat_Slayer
0
200
Member Avatar for acrocephalus

[CODE]while True: fname = raw_input("File name: ") try: fhand = open(fname) break except IOError: print "File {0} cannot be opened. Try again.".format(fname)[/CODE]

Member Avatar for acrocephalus
0
146
Member Avatar for acrocephalus

Or you can do something like [CODE]while True: #... #... if overwrite = 'y': #... break[/CODE]

Member Avatar for TrustyTony
0
141
Member Avatar for Simes

Why do you have so many getter and setter methods? You don't need them, so I recommend removing them. Python has no need for that kind of getters and setters.

Member Avatar for Simes
0
204
Member Avatar for prashanth s j

You can use Regular Expressions. Search the file for that pattern, get the "guid" number, increment it by one, then write it. I haven't done regex in a while, so I'm not sure about the syntax.

Member Avatar for jcao219
0
143
Member Avatar for echellwig

I can't think of anything. If it is in the same directory, then that line should work. Check your spelling of the module name? Sometimes it is something simple.

Member Avatar for ultimatebuster
0
198
Member Avatar for pyprog
Member Avatar for doomas10

I'm very glad that you like Python. When you get more and more experienced in Python, it will get easier to translate your thought process into code. So, when I think of a list of words that have individual values connected to them, then I usually think of Python's dictionaries. …

Member Avatar for TrustyTony
0
420
Member Avatar for vlady

Just as tonyjv suggested: [icode]str(bin(13))[2:].zfill(10)[/icode]

Member Avatar for TrustyTony
0
173
Member Avatar for echellwig

Definitely Jython. It's Python that is implemented on the Java platform. Look into it at [URL="http://www.jython.org/"]http://www.jython.org/[/URL].

Member Avatar for jcao219
0
118
Member Avatar for Skyelher

[icode]while True[/icode], or any indefinite loop is integral to Python. All programs written in Python should have at least one of them.

Member Avatar for griswolf
0
150

The End.