226 Posted Topics
Re: [QUOTE=persianprez;1167551]For my extra credit, I'm supposed to generate the longest chain from 1-1000000, I wan't to know if it is correct..here is my code: the caller [CODE] start = 1 end = 1000000 longest, chain = -1, -1 #choiceX(start) for i in range((end-start)+1): if choiceX(start) > longest: longest=start chain=choiceX(start) start+=1 … | |
Re: [QUOTE=Oron123;1165832]hi, i have a big exe program that i wrote in c# (big means that i have a lot of class in it), i want to write a script in python that will check the program. what is the right way to check the program, convert the c# program to … | |
Re: I think cx_Freeze supports python 3.0 [URL="http://cx-freeze.sourceforge.net/"]http://cx-freeze.sourceforge.net/[/URL] | |
Re: [QUOTE=jeffery12109;1166015]I know how to make classes. I'm just asking for your suggestion. I think you should use this instead if using classes [CODE]class monster(): def __init__(self, hp, type, attackDmg, defence): self.hp = hp self.type = type self.attackDmg = attackDmg self.defence = defence def attacker(self, unitBeingAttacked): dmgDone = self.attackDmg*unitBeingAttacked.defense birdMon = … | |
![]() | Re: Well, my initial comment is, great work! If this is your first program, then you are doing really great! [B]What is good:[/B] [LIST=1][*]You have a [icode]while True:[/icode]! It might not seem like much, but your use of it indicates that you really understand how loops work. [*]You are using [icode]if … ![]() |
Re: make it a raw string "\" escapes! [code] string=r'\xb4\xe0\xa0LH/\xefO\xc9|y7&"Af' len(string) [/code] | |
Re: [QUOTE=larrywjr;1160816]Yes I did run python-2.6.4.msi for Python on Windows. When I installed Python. Python itself works fine. Also, I succeeded in downloading this "Packager", Py2exe, on a separate computer. That computer does not even have Python on it. I apologize but I might be missing something basic in my understanding … | |
Re: [CODE]def decorator(function): def wrapped(*args,**keywargs): print("Decorated") return wrapped class MyMetaClass(type): def __new__(meta,classname,bases,classDict): for name,item in classDict.items(): if hasattr(item,"__call__"): classDict[name] = decorator(item) return type.__new__(meta,classname,bases,classDict) class MyClass(object): __metaclass__ = MyMetaClass def __init__(self): print("This is my class.") def method(self): print("This is my method.") x = MyClass() x.method() [/CODE] That's how I would do it. … | |
Re: Can you explain the details of the file you want to split? if each line is like this: "A,B,C 1,2,3", you can do str.split(" ") and you'll get: ["A,B,C","1,2,3"] and do another str.split(",") and you'll have nice organized lists and go from there | |
Re: [QUOTE=Pupo;1142188]Hi. Notepad is on your PATH, inside Windows directory. For other programs to be launched, i guess you should call them with the complete path, like c:/Program\ files/Program/My_program.exe I don't use Windows, so I'm guessing.[/QUOTE] almost, Windows is weird with backslashes (and also case insensitive) "C:\Program Files\Program\my_program.exe" | |
Re: [QUOTE=pankajpriyam;1141510]Hi, error: [Errno 10061] No connection could be made because the target machine actively refused it[/QUOTE] I recognize that error. I had it before when I was making an internet chat client in IronPython. It happens when the server is behind a firewall or something. It happened to me because … | |
Re: try this: [CODE] response = input("Hit or stay: ").lower() if (response != "hit") and (response != "stay"): #bad response pass else: #good response pass [/CODE] the above post might not work since if the user types something other than number, int() won't work, and there will be an exception. | |
Re: That would be Interop. It's certainly possible with Python, you just have to use the right modules. Although in my opinion it would be easiest in a .NET language, like C# or VB.NET, but that might be because I am more fluent in .NET, and I know that .NET provides … | |
Re: Well, with some help from icky microsoft .net that is very possible with IronPython. I'm afraid that's the only way to go. | |
Re: Oh you can't do that [I]easily[/I] with normal python! Gotta use interop Learn .NET and IronPython (or any .NET language) and use Microsoft.Office.Interop.Word Since Microsoft is .NET, Word can be accessed from .NET the easiest. That's what I would do. Here's something that could help (its a full code snippet): … | |
Re: Define the class first before you make a reference to it! although this might not fix your problem [code] import time from threading import Thread from threading import Lock class MyThread(Thread): def __init__(self, i): Thread.__init__(self) self.i = i self.lock = Lock() def run(self): while True: self.lock.acquire() try: fh = file("fault.txt","a") … | |
Re: Here: [CODE]print u'\u2070\xb9\xb2\xb3\u2074\u2075\u2076\u2077\u2078\u2079'[/CODE] | |
Re: I'm not sure, but Pidgin, the popular chat client uses Aspell. So maybe try that: [URL="http://aspell.net/"]http://aspell.net/[/URL] You can make your own spell-checker refer to this: [URL="http://norvig.com/spell-correct.html"]http://norvig.com/spell-correct.html[/URL] All you need is a text file with a list of correctly spelled words. That you can find at aspell somewhere. | |
Re: Probably insignificant. Just stuff the compiler adds in. | |
Re: Game Programming is very difficult. I don't quite like the blender game engine. I prefer to use Panda3D if I am writing a game in python. First learn python, the language, as a whole. | |
Re: Nowadays you should do : [icode]super(DatePlus, self).__init__(y,m,d)[/icode] I think. Instead of explicitly calling __init__ Also change this: [icode](y, m, d) = self.translate_string(self, arg[0])[/icode] to this: [icode](y, m, d) = self.translate_string(arg[0])[/icode] Also, [icode]type('')[/icode] can be replaced with [icode]str[/icode] | |
Re: You can change player to i if you want. Doesn't matter. You can change it to asdfjklkansns if you want to. | |
Re: Well, the two RANKS and SUITS part of the Card class are unnecessary I believe. The super allows the Positionable_Card class to refer to its parent, the Card class without naming the Card class explicitly. That way, a Positionable_Card object will have a rank and suit just like a Card … | |
Re: well for py2exe just setup the script for the main py file I'm not 100% sure, because IronPython has a compile to exe function, so I never use py2exe | |
This code is IronPython! Won't work with CPython. IronPython - Hello World [CODE] import clr clr.AddReference('System.Windows.Forms') from System.Windows.Forms import Application, Form, Label form = Form(Text="Hello World Form") label = Label(Text="Hello World!") form.Controls.Add(label) Application.Run(form) [/CODE] Editor's note: This post moved from Python GUI Programming sticky thread. Please follow the rules of … | |
Re: I'm not sure, since I don't know much about wxpython. I always code in .Net Perhaps you should make the event handling all inside of the MainWindow class Hopefully that helps, I am about 30% sure. |
The End.