761 Posted Topics

Member Avatar for monstro

Could you give us the offending code and the Traceback? Your explanation is devoid of any information that could allow us to help you. Help US help you!

Member Avatar for monstro
0
251
Member Avatar for desm

You are right as to why this is happening; a variable and a function sharing the same name. From within the class scope, self.number is the variable and self.number() is the function. When you initialize the class, it goes through and recognizes each function then calls __init__ (at least that's …

Member Avatar for desm
0
95
Member Avatar for eibwen

After you open the file for reading you can iterate over each line like so: [code=python] fh = open('myfile.txt', 'r') lines = fh.readlines() fh.close() for each_line in lines: ## split each line now like woooee pointed out above and do your processing... [/code]

Member Avatar for Gribouillis
0
174
Member Avatar for planetPlosion

makeSentence is a function of the class App. It should be called as such [icode]App.makeSentence[/icode]

Member Avatar for planetPlosion
0
340
Member Avatar for Hogg

Here's one making use of list comprehension: [code=python] >>> def FirstLetters( s ): ... return ''.join( [ lett[0] for lett in s.split() ] ) ... >>> FirstLetters( 'My mother used to bake apple pies in the foo bar' ) 'Mmutbapitfb' >>> [/code]

Member Avatar for Hogg
0
6K
Member Avatar for 2ashwinkulkarni

You can identify substrings using the () characters within your pattern; for example: [code=python] >>> import re, os, sys >>> tests = [ 'NM4_ACT', 'NM4_SAND', 'NM3_BOO', 'NM5_FOOBAR', 'NM4_DUMP', 'NM4_SUNSET', 'NM4_SOUTH_VALLEY' ] >>> for each in tests: ... ret = re.search('^NM4_(.*)$', each) ... if ret: ... ret.groups() ... ('ACT',) ('SAND',) ('DUMP',) …

Member Avatar for jlm699
0
107
Member Avatar for sepiso

Here's a few things to get you on your way: [code=python] >>> inp = 'clear|foobar' >>> inp.find('clear|') 0 >>> inp.rfind('|') 5 >>> inp[5+1 : ] # This is slicing 'foobar' >>> inp.split('|') ['clear', 'foobar'] >>> inp.split('|')[1] 'foobar' >>> [/code]

Member Avatar for Gribouillis
0
91
Member Avatar for breakbone

The usage depends on what interface you're using to make your client/server (I've only ever used paramiko); however you could probably make use of a global timeout setting. This way after a set amount of time the recv() operation will throw a timeout exception, which you can catch and handle …

Member Avatar for breakbone
0
163
Member Avatar for FreezeBlink

What? Are you asking about two variables of the same name ? Or are you asking about a private variable that can only change through a public modifier?

Member Avatar for Gribouillis
0
115
Member Avatar for tzushky

Have you looked into pyExcelerator at all? I'd say it's worth a shot. [url=http://sourceforge.net/projects/pyexcelerator]link[/url]

Member Avatar for Gribouillis
0
2K
Member Avatar for darkMatter2008

Not exactly sure what it is you're looking for. But many built-in objects can have the str() function applied to them with little problem. If it's a custom class or similar you may need to look into the Pickling module. I don't know if you plan to use the string …

Member Avatar for Gribouillis
0
106
Member Avatar for knish

Since there is no A2 in your code; and judging by the content of the error message; I would assume that you have imported the maya.cmds module incorrectly. I would look into the documentation for an example of how to properly use said module.

Member Avatar for jlm699
0
861
Member Avatar for fmv2011

Here's how you could iterate through a file: [code=python] fh = open( 'myFile.txt', 'r' ) inp = fh.readlines() fh.close() for each_line in inp: # Do something here [/code] All you'll need to do is make a counter and increment it when you find what you're looking for.

Member Avatar for Ene Uran
0
371
Member Avatar for john_bboy7

If your regex doesn't match anything it returns a None, which gets stored to m. You should have a check before accessing m.groups by saying [icode]if m:[/icode]

Member Avatar for john_bboy7
0
187
Member Avatar for flagrl

You can interact with Python and execute code as you see fit. My favorite thing about Python is being able to simply type in examples to the Interpreter and see how my programs will react to different test cases.

Member Avatar for jlm699
0
27
Member Avatar for StarryEyedSoy

Hmm, it's hard to say exactly what's wrong without having an example of the contents of table.csv; however upon initial inspection I see a glaring problem. Since you're not incrementing counter by 1 (rather a variable length), I would imagine you're missing the opportunity to enter the [icode]while counter == …

Member Avatar for jlm699
0
140
Member Avatar for toolbox03

I don't know about getopt but all of those things are stored in the list stored under sys.argv [code=python] >>> import sys >>> sys.argv[0] >>> len(sys.argv)[/code] Try those lines and then you should be able to handle the command line arguments yourself.

Member Avatar for jlm699
0
114
Member Avatar for Mazille

There are a number of problems here. First of all, that text file contains five letter words that are all appended together without any whitespace whatsoever. Secondly, do not use file as one of your variable names. As you can see above, file is highlighted in purple meaning that it …

Member Avatar for Mazille
0
2K
Member Avatar for bimaljr

[code=python] import sys, os if len(sys.argv) != 2: print 'Usage: python copy.py <file_to_copy>' sys.exit(0) if sys.platform[:3] == 'win': os.system('copy %s %s' % (sys.argv[1], 'copy' + sys.argv[1])) elif sys.platform[:5] == 'linux': os.system('cp %s %s' % (sys.argv[1], 'copy' + sys.argv[1]))[/code]

Member Avatar for bimaljr
0
111
Member Avatar for ChrisP_Buffalo

In my experience with regex you can combine two different regexes with an '|' (or operator). So within the quotes just place a '|' between each regex (without single quotes)' Like so: [code=python] tennis_players = re.compile("<div class=\"entrylisttext\">([\d+]*)</div>|playernumber=[A-Z][0-9]+\" id=\"blacklink\">([a-zA-Z]+, [a-zA-Z]+)|pointsbreakdown.asp\?player=[A-Z][0-9]+&ss=y\" id=\"blacklink\">([0-9]+)|playeractivity.asp\?player=[A-Z][0-9]+\" id=\"blacklink\">([0-9]+)", re.I | re.S | re.M)[/code]

Member Avatar for bvdet
0
5K
Member Avatar for flagrl

This doesn't belong in this forum... however I imagine when you say you "started the CD up" you mean that you're still in Windows and you just popped it into your disc drive. You need to understand that when it comes to an operating system, it's not just another program …

Member Avatar for tomleo
0
84
Member Avatar for PoovenM

When using psycopg2 your operations are only transactions. In order to get your transaction to commit to the database you'll need to issue a [icode]conn.commit()[/icode] command.

Member Avatar for jlm699
0
263
Member Avatar for keripix
Member Avatar for jlm699
0
341
Member Avatar for Das246

wxPython, like most other GUI modules is event driven. This means that until something triggers an event, processing is more or less waiting for something to happen. I'm not sure what you mean by appending text afterwards? Do you mean literally after the mainloop() statement? Because the program stays in …

Member Avatar for jlm699
0
153
Member Avatar for axn

A very crude method would be to capture your output, and then execute the same command via os.system or a similar call. Alternately you could make use of smtplib to send the email to a mail server's listener, and send it that way. Example of [url=http://docs.python.org/lib/SMTP-example.html]using smtplib[/url]. Keep in mind …

Member Avatar for woooee
0
272
Member Avatar for ChrisP_Buffalo

[] designates a group of characters to match.. you had [d+] in there, meaning that you wanted to match any of the digits 0-9 as well as the plus symbol. An equivalent statement would be [0-9+], or typing the entire set of digits out would be [0123456789+]. By placing an …

Member Avatar for jlm699
0
64
Member Avatar for flagrl

Google Byte of Python and Dive into Python. Both are great launching pads for getting into some serious Python programming. The latter is more for people that are familiar with programming languages in general, while the first is more for somebody that is using Python as their first programming language …

Member Avatar for jlm699
0
96
Member Avatar for StarryEyedSoy

You can simply store the data of the previous line in a variable, so that on the following iteration you can calculate with the previous line and the current one.

Member Avatar for StarryEyedSoy
0
112
Member Avatar for dinilkarun

What do you mean freeze them but still scroll? Would you simply want to not allow the user to expand any items in the tree ? And not allow any checklistbox items to be 'checked'? This would be as simple as binding an event to those actions and if your …

Member Avatar for jlm699
0
74
Member Avatar for siberian1991

You're on the right track! However I typically like to use slicing when I know precisely where on a line the information that I'm looking for is going to be. Here's what you suggested in a friendly python format: [code=python] inp = open('SAdatabsse.txt', 'r') outp = open('SAdatabse2.txt', 'w') for eachline …

Member Avatar for jlm699
0
215
Member Avatar for thatoneguyx

[code=python] def chckguess(guesses) #guesses = 0[/code] By declaring [icode]guesses = 0[/icode] at the beginning of your function you are resetting its value. Also guesses being defined within the function only gives that variable scope within that function. You should either have that variable be global, and then within the function …

Member Avatar for jlm699
0
150
Member Avatar for supriyav

You will need to download and install pyExcelerator as it is not distributed with the standard Python. Link: [url=http://pypi.python.org/pypi/pyExcelerator/0.5.3a]Py Package[/url] You cannot create a csv file with multiple sheets (tabs), as the format does not allow it.

Member Avatar for jlm699
0
381
Member Avatar for besktrap

You would need to keep track of the boundary of 'square', which would be the leading edge of movement (this gets really complicated if square is rotating while falling), and then do a comparison to make sure that the leading edge isn't at the line... if it is past the …

Member Avatar for besktrap
0
114
Member Avatar for dinilkarun

This is not a Python issue, it is an Access issue. If you can perform the query in Access it will work through Python you just need to be careful as to how you format your query. If you paste the query that you would use from within Access, we …

Member Avatar for woooee
0
1K
Member Avatar for ub007
Member Avatar for lllllIllIlllI

Could your main thread keep a dynamic dictionary or list of the process ids ? Then you could perform some basic system commands to see which theads are still running and kill them if necessary?

Member Avatar for jlm699
0
99
Member Avatar for dinilkarun
Member Avatar for dinilkarun
0
2K
Member Avatar for sardarji

[code=python] >>> md = {} >>> md['a'] = [1,2,3,4] >>> md['h'] = (1,2) >>> md['t'] = {'first':[9,8,7], 'sec':(1,2,3,4), 'h':'foobar'} >>> md {'a': [1, 2, 3, 4], 'h': (1, 2), 't': {'h': 'foobar', 'sec': (1, 2, 3, 4), 'first': [9, 8, 7]}} >>> [/code] Is that what you mean by multiple …

Member Avatar for vegaseat
0
77
Member Avatar for MikeyFTW

[QUOTE=MikeyFTW;651479] i want it to be able to load the program up and then be able to choose from addition as well as substraction like a button for each on start up or something.[/QUOTE] What if you had a radio button choice. So that addition and subtraction could be chosen …

Member Avatar for jlm699
0
388
Member Avatar for packetsmacker

Yes there are not only GUI toolkits for PYthon where you could make a very nice looking UI for the user, but python scripts can also simply be double-clicked to have them execute.

Member Avatar for jlm699
0
96
Member Avatar for ub007

I've used a module called paramiko to open a tunnel into another machine and execute commands remotely. It worked very nicely.

Member Avatar for jlm699
0
110
Member Avatar for SUBHABRATAIISC

Before your for loop you should initialize a5 and a6 as ''. Then within your loop instead of a5 = or a6 = you should use += to concatenate.

Member Avatar for woooee
0
83
Member Avatar for elhallouf

if you can type exactly that command into your command window, then os.system() with *exactly* that command will work. What doesn't work about it? Are you getting an error?

Member Avatar for jlm699
0
115
Member Avatar for thatoneguyx

What have you tried so far? Give us what you've already done and we can help you along. However we cannot simply do this for you because then you wouldn't learn anything.

Member Avatar for jlm699
0
85
Member Avatar for safir8100

First, you need to use code tags on your code to make it readable and not lose your inentation. Your line [icode]for (first, second) in pairs:[/icode] is along with your error suggesting that pairs is being passed in as an integer. When you provide an example code it would help …

Member Avatar for vegaseat
0
80
Member Avatar for dinilkarun

When you are calling wx.DirPickerCtrl( ) simply place the size that you want in the initialization like so: [icode]wx.DirPickerCtrl( self, -1, '', 'My Dir Picker', size = (a, b) )[/icode] where a and b are the desired dimensions. You could also set the size after the fact with [icode] my_picker.SetSize( …

Member Avatar for jlm699
0
146
Member Avatar for Mazille

> `yIntercept = y1 - (((y2 - y1)/(x2 - x1))(x1))` Yes, Python is not a scientific calculator so it does not know that `(x-5)(x-4)` has an assumed multiplication between parenthesis. You will need to be more specific so change your line to yIntercept = y1 - ( ( ( y2 …

Member Avatar for Mazille
0
137
Member Avatar for linkrulesx10

There are a few possibilities I can think of, but probably the most straight forward: [code=python] >>> li = [ 1, 2.3, 4e-5, 'hey!' ] >>> for item in li: ... test = str(item) ... if test == item: ... print item, 'String!' ... else: ... print item, 'Not String!' …

Member Avatar for linkrulesx10
0
5K
Member Avatar for MikeyFTW

Here are a few modifications I made: [code=python] name = raw_input("\t\t\tPlease Enter Your Name: ") print print "\t\t\t\tHello", name print "\t\t\tWelcome to my Mathematics Game" # Selecting the operation of Addition and Substraction followed by the difficulty print operation = str(raw_input("\t\t\tAddition (A) or Substraction (S)")) if operation == "A" or …

Member Avatar for MikeyFTW
0
192
Member Avatar for ALPHA_Wolf
Member Avatar for woooee
0
187

The End.