3,386 Posted Topics

Member Avatar for Frensi

You have only the Robots instead of Robot as name error, otherwise everything seems fine. class Robot: '''Represents a robot, with a name.''' #A class variable, counting the number of Robot population = 0 def __init__(self, name): '''Initializes the data ''' self.name = name print("(Initializing {0})".format(self.name)) #When this person is …

Member Avatar for Gribouillis
0
310
Member Avatar for satnav_8
Member Avatar for Skrell

This code seems to be explained with diagram of the state machine at http://www.python-course.eu/finite_state_machine.php

Member Avatar for Skrell
0
294
Member Avatar for gerbil

Use **Inline Code** (backticking), less painfull than escapes: glob pattern `H:\\*`

Member Avatar for gerbil
0
186
Member Avatar for ryantroop
Member Avatar for ryantroop
0
278
Member Avatar for deepthought

The response seems not alphanumeric, you must find out how the response should be interpreted and use struct module, for example.

Member Avatar for deepthought
0
134
Member Avatar for gem.gonzales.9

You have a for without any statements in it at line 38, as line 37 ends in ;. It looks strange for me as it has not effect except increasing i, so line 39 is in effect d += num[b]. Also learn to use proper indention for your code.

Member Avatar for Vish0203
0
116
Member Avatar for 3e0jUn

You can use else: instead of second if at line 5, otherwise correct, even the whole function seems pointless as it is only print 'Account' + ('exists' if str(myobj) in config_file else "doesn't exist") Where myobj is of type of the your class definition. I would at least define only …

Member Avatar for Gribouillis
0
166
Member Avatar for scott.richardson.988373

You read the lines until you find 'look for this line', then you discard lines until you find 'until this line is found' (you read them, but do not save them), then loop again to look for 'look for this line'. At end you write out all lines you saved, …

Member Avatar for scott.richardson.988373
0
194
Member Avatar for Ancient Dragon
Member Avatar for toyotajon93

If len of list is 14, last index is 13, so line 10 does not make sense. It is more clear to index the last element of list with -1.

Member Avatar for Gribouillis
0
173
Member Avatar for wassupB
Member Avatar for shsh111
Member Avatar for cwarn23

What you mean Punch Cards, that is media, not computer language. Language of implementation is typicallyl Pascal, so the compiler is self hosting: [QUOTE]The first Pascal compiler was designed in Zürich for the CDC 6000 series mainframe computer family. Niklaus Wirth reports that a first attempt to implement it in …

Member Avatar for finalist
0
1K
Member Avatar for Mahesh57
Member Avatar for Gribouillis
0
396
Member Avatar for aint

If you have only not optional alternatives without repeats in [], you could do something like this to avoid complicated transformations (you could improve the matching with more advanced string matching algorithm) : dna = r'atata[atg]ca[atgc]atatagtagcctgt' grouping = [] s = set() reading = False for acid in dna: if …

Member Avatar for TrustyTony
0
319
Member Avatar for dsplayer14

Every time group of statements follows, that line ends in colon and the block is indented.

Member Avatar for dsplayer14
0
4K
Member Avatar for hughesadam_87

This is not about your own code, but I find this too hackish > if not min(c.isalnum() or c=='_' for c in name): raise ValueError('Type names and field names can only contain ' 'alphanumeric characters and underscores: %r' % name) I would prefer to use something like (untested) if any(not …

Member Avatar for TrustyTony
2
537
Member Avatar for vishu.bhavsar
Member Avatar for TrustyTony
0
170
Member Avatar for munieb

word=raw_input('enter the word you want to search\n') for fn in '2.txt', '3.txt': with open(fn) as this_file: print fn, 'has', this_file.read().count(word), word

Member Avatar for snippsat
0
170
Member Avatar for Plazmotech
Member Avatar for deepthought

I hope the message is expected in alphanumeric string not as binary values.

Member Avatar for TrustyTony
0
651
Member Avatar for Squidge

We seem to be experiencing determined PM spammer attack and we are raising measures to help block such cases. We are sorry that big amount of these junk messages got sent, you can PM *happygeek*, for example http://www.daniweb.com/members/961217/queenjobe (I announced just now that) any such posters info page url, in …

Member Avatar for happygeek
0
135
Member Avatar for funnymoney
Member Avatar for TrustyTony
0
122
Member Avatar for Iceman10284

Looks pretty standars stuff found in many codes in our Code Snippet section. Cut is usually not done but it would be simple to do: Determine cut_point deck = deck[cut_point:] + deck[:cut_point]

Member Avatar for HiHe
0
124
Member Avatar for Plazmotech

Post your code and ask specific questions, I can not catch the connection with your request with Python. > What language is Dwarf Fortress programmed in? Would you ever switch to or develop another project in a language like OCaml(pronounced o-camel)? (Aaron Ogden) I wrote DF in C with some …

Member Avatar for sepp2k
0
129
Member Avatar for shibu2all

Inorder -> E is the root, I think. The problem is when to move from innode to child nodes. I suspect that this is supposed to be balanced binary tree, but even that is not given by th poster. In that case A would be left child and H right …

Member Avatar for iamthwee
0
118
Member Avatar for 3e0jUn
Member Avatar for peterparker
0
255
Member Avatar for jwalajoseph

You must also convert the ip number to normal number or keep it as string. I have posted as one of my first Code Snppets functions for the conversion.

Member Avatar for ryantroop
0
130
Member Avatar for hughesadam_87

You assume the correct form and use try...except for input check. Snippsat gave good quote about it, even Gribouillis class was neat coding, only that is not the Pythonic way. Have you read about concept of duck typing?

Member Avatar for hughesadam_87
0
441
Member Avatar for manticmadman

That is software page, not Python module. Check http://www.astro.washington.edu/users/rowen/AstroPy.html

Member Avatar for TrustyTony
0
55
Member Avatar for hughesadam_87

There is few views you can have in OOP and Python. This is from a guy more familiar with structured/modular programming than object oriented. 1. Python lets you use objects when you need, otherwise do not bother. That means generally that when you have many instances you want to create, …

Member Avatar for hughesadam_87
0
159
Member Avatar for lil_bit

Sorry for the spanking, it is sometimes diffiult to post suggestgions to OP so they are understood, not give ready answer to home work etc... Your post kind of remainded me of my own post to newbies, which I used to link to in my signature before Markdown change, so …

Member Avatar for Reverend Jim
1
207
Member Avatar for bendoveryou

I do not understand the else statement of the first while (and lot of other things of your script) as there is not any break statements inside the loop, which would not enter in it. I have no idea what is your logic.

Member Avatar for TrustyTony
0
119
Member Avatar for nishant.rathee

You are trying to call by reference, when parameters are by value. Integer is not standard C type, how is it defined.

Member Avatar for HiHe
0
580
Member Avatar for Frensi

And there is of course one of my snippets for safer alternative for the code snippet competition, http://www.daniweb.com/software-development/python/code/426488/mathexpression-safer-evaluation , if you want to make that your user does not make joke of erasing your hard disk empty.

Member Avatar for HiHe
0
6K
Member Avatar for depy

Paste your code by pushing **Code** from reply menu bar and explain your problem. We are not home work automate, but want to help people to learn.

Member Avatar for ZZucker
0
121
Member Avatar for ThePythonNoob

I do not understand your error explanations, your code seems working OK. Naturally you must lift the finger from key to push it again and the message you posted is normal SystemExit message (sys.exit() is same as `raise SystemExit`)

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

Maybe you would benefit from my post some time ago http://www.daniweb.com/software-development/python/threads/426837/echo-user-specified-text#post1826036 ?

Member Avatar for TrustyTony
0
187
Member Avatar for dwhite12
Member Avatar for 3e0jUn

"without external modules", I would not think it would be easy "without nonstandard modules" or "with only modules included with Python base", sure it is possible to do socket programming, you usually do not directly manipulate signals in Ethernet, but use 'tcp/ip stack'.

Member Avatar for 3e0jUn
0
159
Member Avatar for duckduck

Your code failed to execute with the strange "wt" mode, with "w" mode everything seemed to work in Python 2.7.3

Member Avatar for TrustyTony
0
140
Member Avatar for Arash-Sh
Member Avatar for Dani

Actually I was ready to ask after the count, just checked these recent threads. It is kind of dounting when writing code snippets to demonstarate things and finalizing them reasonably well, my only feed back have been occational kudos from Gribouillis. And I in my turn have commented his more …

Member Avatar for gerbil
0
206
Member Avatar for matthewkeating
Member Avatar for Gribouillis
0
613
Member Avatar for kwolfe

You specify path relative path relative to ftp root directory, you have Windows file path specified. Check first that the ftp you try works from command line ftp, before trying to do it with ftplib.

Member Avatar for TrustyTony
0
199
Member Avatar for lil_bit
Member Avatar for zachattack05

If somebody entered 300 spaces before and after the email address, I quess it would be legitimated. You are stripping spaces from ends, aren't you?

Member Avatar for zachattack05
0
188
Member Avatar for chriswelborn

Looks quite a tidy effort, I would like if you changed to Python PEP8 style naming like print_report() and would indent with 4 spaces. I personally find it more clear also to use startswith method instead of == with slice. Another suboptimal thing is that you are using if where …

Member Avatar for chriswelborn
2
367
Member Avatar for javanub123

How about just reading the file to clipboard? Then just use normal paste. http://www.daniweb.com/software-development/python/code/422325/using-clipboard-from-python

Member Avatar for javanub123
0
123

The End.