RE: AttributeError: ' ' object has no attribute ' '
Date: Sat, 23 Feb 2013 10:22:54 -0800 Subject: AttributeError: ' ' object has no attribute ' ' From: matt.doolittl...@gmail.com To: python-list@python.org I am using Ubuntu 12.10, and Python 2.7.3, GNU Radio Companion v3.6.3. I get the this error in terminal: in __init__ self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback) File /usr/local/lib/python2.7/dist-packages/gnuradio/gr/hier_block2.py, line 54, in __getattr__ return getattr(self._hb, name) AttributeError: 'gr_hier_block2_sptr' object has no attribute 'set_callback' I have been getting this error in multiple programs. So what is stopping the program here? There is no Attribute .set_callback obviously. But where is this attribute missing from exactly and how do i put it where it should be? -- http://mail.python.org/mailman/listinfo/python-list That error means that 'gr_hier_block2_sptr' doesn't have enough information to proceed. If you look at the top of the defintion (for example, 'def gr_hier_block2_sptr, [attribute], [another attribute]'), that's where you should find .set_callback. If it's not there, you'l just need to add it to the end; if it is there, then the attribute is probably given a different name somewhere else (so you'll just need to find out its new name and update the existing entry). -- http://mail.python.org/mailman/listinfo/python-list
RE: What are the minimum requirements to get a job in?
Date: Thu, 13 Dec 2012 18:49:32 -0800 Subject: What are the minimum requirements to get a job in? From: suresh.pinn...@gmail.com To: python-list@python.org My aim is to get a job into google or cisco or facebok. I have basic knowledge in python,c,java and good in javascript,html,css, database concepts. If i learn django and python. Shall I get my dream job? Please suggest me -- http://mail.python.org/mailman/listinfo/python-list You'd need a fair bit of industry cred to get picked up at a place like Google, I'd imagine. By all means, keep pursuing your dream, but temper your expectations. -- http://mail.python.org/mailman/listinfo/python-list
Issue with seeded map generation
Hey, all! I've managed to get my project to a semi-playable state (everything functions, if not precisely the way I'd like it to). One small issue is that when the player movs from one level to the next, the items and monsters in the previous level all 'reset' and return to the positions they had when the level was seeded. I've puzzled over (and attempted) quite a few workarounds, and had no success. I don't want to pickle the entire level (that would be overkill for what I need), but I want to update the item/monster locations so the player can drop an item and come back to it later. Should I add something to the 'drop_item' function, or call soemthing in make_map? -- http://mail.python.org/mailman/listinfo/python-list
RE: Getting a seeded value from a list
Just a quick update: after enlisting some help from a friend, we managed to get things working :) Thanks for all the help. In the area of items and monsters, they're both chosen from lists, based on some simple selection criteria (number per room, total per level, chance of appearance). Now, the major task is to reconfigure the distribution system to let items and monsters stay in place between levels. Date: Sat, 24 Nov 2012 09:32:46 +1100 Subject: Re: Getting a seeded value from a list From: ros...@gmail.com To: python-list@python.org On Sat, Nov 24, 2012 at 3:27 AM, Prasad, Ramit ramit.pra...@jpmorgan.com wrote: Steven D'Aprano wrote: On Wed, 21 Nov 2012 14:41:24 +1100, Chris Angelico wrote: However, this still means that the player will see the exact same level regenerated every time, absolutely fresh. As previously stated in this thread, that's not usually a good thing for encounters, treasure, etc. Once some nasty critter has been killed, he should STAY killed! :) Why? That isn't true in real life, why should it be true for games? It is not true in all games. I have seen games where treasures regenerate in the same location except for key items. Same goes for enemies (where only bosses do not regenerate). It really just depends on the type of game you are playing--designing in this case. Perhaps they regenerate, but do they regenerate from the exact same random seed? For instance, in Murkon's Refuge, the maps are handcrafted and thus constant every time you enter a particular level - but go downstairs and upstairs, and the monsters and treasure regenerate, different from last time. Of course, if the idea is that you're rewinding time, then it makes good sense for you to see the exact same pattern of enemies. ChrisA -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
RE: Is it bad style to override the built-in function `type`?
(This comes from my experience writing interactive fiction with the TADS workbench; YMMV) As a rule, it's generally unwise to modify built-in variables without thoroughly documenting your changes. Your modifications might not hold up if the built-in definitions are revised (which would break your program) and you could introduce later version/compatibility issues with other things that use/need the 'standard' definitions. That said, if done cautiously, modifying the built-ins can have a net benefit; just be careful to indicate what you've changed so you can debug it properly, and -- if possible -- distribute yoru modified code along with a copy of the original, so that if issues arise, your users can restore the stable code without digging around in the guts of the software. [...] | I know it's a common beginner's mistake to incautiously override | built-in functions. However, we put in a lot of research and have come to | the conclusion that, if Python had not already defined it, `type` would | be the best name. We are now trying to evaluate how bad the disadvantages | you mention are in comparison to the advantage to having a name that is | more intuitive to use in the problem domain. | | Can you somehow relate to my explanations, or are your experiences | with overwriting built-in variables so bad that you would advise to | never ever do it? My own experience says that it is a thing best avoiding without a truly amazing reason not to. I urge you not to: type(foo) is a very basic Python idiom and you're breaking it. One day it _will_ bite you or your users. You will understand, but I would give goods odds that some of your users will not the day they go to examine the type of an object for perfectly normal pythonic reasons. Example: I have a module that stores objects and they have as a primary key a name and a type - not Python types, just strings. Accordingly I have a similar situation to yours: the desire to use the word type. Fortunately for me, as an attribute in (usually small) code chunks I can usually go: t = foo.type ... work with t here ... Where I must pass one as a parameter I use the common convention of naming the parameter type_ at the receiving end. For the calling end, as in your case, you want to use: type(blah) Is it at all possible to make all uses of your type function method calls? Eg: something.type(text to type) It avoids the overloading while keeping your desired name. -- Cameron Simpson Wouldn't it be great if all emergency stopping situations occurred on your favourite bit of road..you'd probably know about it before it happened and would be able to take other evasive action. - Neville Brabet -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Getting a seeded value from a list
Hello! Clueless noob again! :) This time around, I'm trying to figure out the random.seed() function -- specifically, I'd like to retrieve the seeded values from a list (which I've called levelSeed), and use them in a random-dungeon generator. The numbers are generating and storing properly, but I can't find any examples online that aren't specific to a particular purpose (such as mathematics, arrays, and the like). Would I use 'getstate' when the dungeon is generated, or is there another method that would be better suited to the task? -- http://mail.python.org/mailman/listinfo/python-list
RE: Writing game-state data...
To: python-list@python.org From: breamore...@yahoo.co.uk Subject: Re: Writing game-state data... Date: Fri, 9 Nov 2012 07:37:56 + On 09/11/2012 07:20, Graham Fielding wrote: Hey, folks, me again! I've been puzzling over this for a while now: I'm trying to write data to a file to save the state of my game using the following function: def save_game(): #open a new empty shelve (possibly overwriting an old one) to write the game data file_object = open('savegame.sav', 'wb') file['map'] = map file['objects'] = objects file['player_index'] = objects.index(player) #index of player in objects list file['inventory'] = inventory file['game_msgs'] = game_msgs file['game_state'] = game_state file['stairs_index'] = objects.index(stairs) file['dungeon_level'] = dungeon_level file.close() However, while 'savegame.sav' is created in the directory I specify, the function dies on file['map'] = map. This is the end of the stack trace: File C:\Python Project\Roguelike.py, line 966, in save_game file['map'] = map TypeError: 'type' object does not support item assignment Now, the map is randomly generated -- could that be an issue? Should I just scrap the current system and use pickle? Please always give the complete stack trace, it's provided for a purpose. Here I'll grope around in the dark and guess that you need file_object = shelve.open(... -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list Here's the full stack trace: File C:\Python Project\Roguelike.py, line 1048, in module main_menu() File C:\Python Project\Roguelike.py, line 1030, in main_menu play_game() File C:\Python Project\Roguelike.py, line 1007, in play_game player_action = handle_keys() File C:\Python Project\Roguelike.py, line 717, in handle_keys quit_menu() #exit game File C:\Python Project\Roguelike.py, line 698, in quit_menu save_game() File C:\Python Project\Roguelike.py, line 909, in save_game file['map'] = map TypeError: 'type' object does not support item assignment What I'm trying to do is figure out a way to get the game to save its state; I compiled it to an EXE using py2exe, but after that, the game refuses to hold onto its data. Thanks for all the help! -- http://mail.python.org/mailman/listinfo/python-list
Writing game-state data...
Hey, folks, me again! I've been puzzling over this for a while now: I'm trying to write data to a file to save the state of my game using the following function: def save_game(): #open a new empty shelve (possibly overwriting an old one) to write the game data file_object = open('savegame.sav', 'wb') file['map'] = map file['objects'] = objects file['player_index'] = objects.index(player) #index of player in objects list file['inventory'] = inventory file['game_msgs'] = game_msgs file['game_state'] = game_state file['stairs_index'] = objects.index(stairs) file['dungeon_level'] = dungeon_level file.close() However, while 'savegame.sav' is created in the directory I specify, the function dies on file['map'] = map. This is the end of the stack trace: File C:\Python Project\Roguelike.py, line 966, in save_game file['map'] = map TypeError: 'type' object does not support item assignment Now, the map is randomly generated -- could that be an issue? Should I just scrap the current system and use pickle?-- http://mail.python.org/mailman/listinfo/python-list
Issues with python/libtcod
Hey, all. I'm trying to program a roguelike, using the wonderful tutorials written by João F. Henriques (a.k.a. Jotaf), but I've stumbled onto a bit of a problem setting up the game's inventory system, and I was hoping someone could help me out. Here's a code snippet, including the affected line. #def menu(header, options, width): #if len(options) 26: raise ValueError('Cannot have a menu with more than 26 options.') #calculate total height for the header (after auto-wrap) and one line per option #header_height = libtcod.console_height_left_rect(con, 0, 0, width, SCREEN_HEIGHT, header) #height = len(options) + header_height In a nutshell: def menu() is an all-encompassing 'menu processor' function -- it contains a standardized menu layout that can be called, from anywhere in the stack, to create a generic menu. When I launch the game to check things out, everything runs smoothly until I try to open the inventory window -- at which point, IDLE tosses up an AttributeError: File C:/Python Project/Roguelike.py, line 602, in module player_action = handle_keys() File C:/Python Project/Roguelike.py, line 531, in handle_keys chosen_item = inventory_menu('Press the key next to an item to use it, or any other to cancel.\n') File C:/Python Project/Roguelike.py, line 487, in inventory_menu index = menu(header, options, INVENTORY_WIDTH) File C:/Python Project/Roguelike.py, line 447, in menu header_height = libtcod.console_height_left_rect(con, 0, 0, width, SCREEN_HEIGHT, header) AttributeError: 'module' object has no attribute 'console_height_left_rect' I've tried moving the entire def menu() function to various sections of the stack, I've changed its arguments manually, and I've even removed the affected line entirely to see if that would help; nothing seems to work, and it's only when def menu() is called that this happens. Anyone got any ideas what could be going flooey?-- http://mail.python.org/mailman/listinfo/python-list