15,185 Topics

Member Avatar for
Member Avatar for funnymoney

A sparse vector is a vector whose entries are almost all zero, like [1, 0, 0, 0, 0, 0, 0, 2, 0]. Storing all those zeros wastes memory and dictionaries are commonly used to keep track of just the nonzero entries. For example, the vector shown earlier can be represented …

Member Avatar for TrustyTony
0
120
Member Avatar for hughesadam_87

I have a simple class that stores attributes: In [1]: class Test(object): ...: a=10 ...: b=20 I have a function that returns attributes using attrgetter, and it accepts these through the args parameter to allow a user to pass various attribute fieldnames in. For example: In [4]: def getstuff(*args): ...: …

Member Avatar for hughesadam_87
0
492
Member Avatar for tunisia

I work in the AV industry and there is a whole set of hardware/software for controlling Ip and serial devices. I'm interested in writing some python code for bench testing projectors and video teleconference unuts, as I think it would be easier and more efficient and a good way to …

Member Avatar for tunisia
0
370
Member Avatar for Iceman10284

I need help writing this program, any hints, help, guidance will be appreciated. The program needs to provide a menu to the user with the following options: Reset the deck Shuffle the deck Cut the deck Cut to a card. Cut against the computer Exit Each of these options must …

Member Avatar for HiHe
0
121
Member Avatar for Plazmotech

Hey. You all know the game dwarf fortress? I'm pretty sure it uses curses to display it's ascii characters. Although, how can I overwrite the ascii characters with my own font, like dwarf fortress? EDIT: > Post your code and ask specific questions, I can not catch the connection with …

Member Avatar for sepp2k
0
127
Member Avatar for kuchi

I 've a following query that going to use in python api. SELECT n.FIRST_NAME as "NAME", a.STREET_1 as "ST1", a.STREET_2 as "ST2" FROM SCHE.EMPLOEE_NAME n, SCHE.EMPLOYEE_ADDR a WHERE n.eid=a.eid AND n.estatus='ACTIVE' The above query yields the result cursor().execute(sqlQuery) sqlTupleRows=cursor().fetchall(); sqlQueryReturnedDict={}; for sqlTupleRow in sqlTupleRows: columns=cursor().description ...... Here the column names …

Member Avatar for ryantroop
0
204
Member Avatar for narendran_9

Hi Pythonist, I write the code in Python for search and replace the text in all XML files at current directory. But I'm unable to find and replace the text `<tex>` as empty in all XML files. Here I want to remove the text: <tex>z_{1 - \alpha }^2 \,\sigma _{{\rm …

Member Avatar for munieb
0
410
Member Avatar for MacUsers

Greetings all, I'm trying to crate some symbolic links, provided the link doesn't already exist. To do that, this is what I've done: [icode]if not os.path.islink(dst_dir): os.symlink("src_dir", "dst_dir")[/icode] but still I'm getting [icode]OSError: [Errno 17] File exists[/icode] for an existing link. Any idea what am I missing? another question, how …

Member Avatar for trsarg
0
3K
Member Avatar for 3e0jUn

How could I make the return command in Python return a list AS a list, and not as a 'programmer' list? For example, for line in list: return (line) But for some reason it only returns the first element in the list, for example: myList = ['1','2','a','b'] for line in …

Member Avatar for peterparker
0
255
Member Avatar for hughesadam_87

Hi, I've been having trouble posting a code snipet tonight, I keep getting this error: The code snippet in your post is formatted incorrectly. Please use the Code button in the editor toolbar when posting whitespace-sensitive text or curly braces. My code is running fine in wingware IDE with 4 …

Member Avatar for hughesadam_87
0
164
Member Avatar for HTMLperson5

This is a program intended to write text to any file specified var_file = (raw_input('nof$ ') #nof, number of files. try: text = str(raw_input('ttwtf$ ') #ttwtf, text to write to files. print text >>> var_file except ValueError: print "Error: Not a string" main() When the program starts the "`try`" part …

Member Avatar for HiHe
1
172
Member Avatar for jwalajoseph
Member Avatar for peterparker

0 down vote favorite I have written a code to convert decimal numbers into hexadecimal equivalent. The program prints correct value till '2559'. How to get correct values of hexadecimal for larger numbers. Here is my code: ######################################### # Decimal to Hexadecimal Conversion # ######################################### def DectoHex(n): if n <= …

Member Avatar for peterparker
0
1K
Member Avatar for hughesadam_87

I'd like to make a dictionary subclass that takes in positional keywords in addition to the standard *args, **kwargs. I found this example on stackoverflow: class attrdict(dict): def __init__(self, *args, **kwargs): dict.__init__(self, *args, **kwargs) self.__dict__ = self a = attrdict(x=1, y=2) print a.x, a.y print a['x'] b.x, b.y = 1, …

Member Avatar for hughesadam_87
0
717
Member Avatar for hughesadam_87

Hi, I think I have a pretty simple question but my google searches are giving me more information than I need. I think my terminology is not clear. Let's say I'm making a dictionary to hold a datatype very specific to some filetype or data of interest. Let's say I …

Member Avatar for hughesadam_87
0
438
Member Avatar for manticmadman

I am a fledgling at best when it comes to programing. I am trying to acclimate myself with Python's date and time functions. Below is a program I wrote to calculate the Sun rise and set times for a given lat, long. What I am hoping to find out is …

Member Avatar for hughesadam_87
0
360
Member Avatar for manticmadman

I am trying to learn how to install packages into python. Asn example is http://www.clearskyinstitute.com/xephem/. I have no idea how to do this. I have viewed a variety of sites to help, but none really explain how someone with no clue can do this. Any leads welcome. Thanks

Member Avatar for TrustyTony
0
53
Member Avatar for hughesadam_87

Hi, I have been subclassing namedtuple to handle my custom data type: fields=['Query', 'u1', 'Accession] Old = namedtuple('Old', fields, verbose=False) class New(Old): def __repr__(self): return 'Overwriting works nicely' p=New('Hi',2,3) print p >>> 'Overwriting works nicely' What I want to do is to add the behavior that some of my fields …

Member Avatar for hughesadam_87
-1
149
Member Avatar for hughesadam_87

Hi guys, This is more a general discussion of methodology than a specific question. I have been working on a, the primary purpose of which is to store an oddly formatted data file (aka not you classic CSV). At the end of the day, the data is stored in a …

Member Avatar for hughesadam_87
0
156
Member Avatar for Plazmotech

As the title says, I have a flash drive, and a script on that flash drive. Whenever I plug my drive into my Mac OSX, I want a specific Python script that is on my drive to run, and be able to access directories on my computer. Why am I …

Member Avatar for Plazmotech
0
239
Member Avatar for bendoveryou

My script is sapposed to have you choose a number and then spit out that number of 1's and 2's randomly chosen and then count and post how much.could someone help me by telling me what is wrong, i would really apreciate it, here is the script(it is a cmd …

Member Avatar for TrustyTony
0
116
Member Avatar for nahsik

I am learning about networking and programming. I am trying to be a simple IM application. What i am trying to achieve having a server application route messages between computers over the internet creating a simple instant messenger. However i can't find any sort of tutorial for that. I want …

Member Avatar for extr3mex
1
321
Member Avatar for nishant.rathee

I am trying to call functions from a DLL `function oziRepositionWP(Number:integer;lat,lon:double):integer;stdcall; ` I have written the code in python no = c_int(1) lat = c_double(34.00962) lon = c_double(74.80067) var =windll.OziAPI.oziRepositionWP(byref(no),byref(lat),byref(lon)) But i get the message var =windll.OziAPI.oziRepositionWP(byref(no),byref(lat),byref(lon)) ValueError: Procedure probably called with not enough arguments (8 bytes missing) where am …

Member Avatar for HiHe
0
577
Member Avatar for Frensi

Hi again, I'm here to ask another stupid question so I apologize. I'm going to make a calculator in Python but I've ran into a wall, with the tutorials I've been following I've only ever been taught how to add two numbers together. Never have I learned how to add …

Member Avatar for HiHe
0
6K
Member Avatar for depy

Hello python world. I am new to python. I need some help in creating a table. It is an input file as <name>,<age>,<gender>,<marks>. these items can be seperated using a ','. The test part would contain mixed spaces.. e.g Jhones can be written as __JHoneS__. but if has to return …

Member Avatar for ZZucker
0
119
Member Avatar for ThePythonNoob

Hi, I have made a square that will move but there are some bugs in the movement. I can't find anything wrong with the logic which is why I need help ;) You have to press left and right to move the square. The problems with the movement are: 1: …

Member Avatar for ThePythonNoob
0
3K
Member Avatar for 3e0jUn

How do you make Python accept multiple strings and break them down in an input? For example, main = input ('> ') if main == ('ECHO',some_words): print (some_words) But everytime I do that, the some_words string wouldn't be defined. Error Message: Traceback (most recent call last): File "<pyshell#7>", line 1, …

Member Avatar for TrustyTony
0
185
Member Avatar for Dan08

Hi, I just installed PyQt Designer to start creating UI's with python, I've used WxPython and TKinter before, but never really done anything with PyQt. So for some of you this might be a very simple question that I can't seem to find with google. I really like how it …

0
137
Member Avatar for dwhite12

I need to write a code that imports a list of files then goes through each file and rewrites only half the file. Cutting off the file at a key word. If I can make my code print the half I need I can make it write new files with …

Member Avatar for dwhite12
0
231
Member Avatar for PlasmoMage

Hey all I would like to ask a few questions about an idea I had for my forensics class. 1. How hard would it be to create a script that monitored when icons on the desktop are moved? AND (bonus) if they are in a specific placement THEN call a …

Member Avatar for imamyth
0
102

The End.