473,388 Members | 1,207 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

python on window

i have install python on window xp os.
C:/program files/python

i have done print program it working but .py can't working
help me to how i will execute this file this file where i will save
it.
path execution how .
tell me about any envorment veriable in python to set before python
editor run,it path. etc
************************************************** **********
>>print ' sandeep patil'
sandeep patil
>>print ' sandeep "bhagwan " patil ,msc. java j2ee developer"
SyntaxError: EOL while scanning single-quoted string
>>print ' sandeep "bhagwan " patil ,msc. java j2ee developer'
sandeep "bhagwan " patil ,msc. java j2ee developer
>>import posix
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
import posix
ImportError: No module named posix
>>phonebook = {'sandeep':9325,'amit':9822,'anand':9890}
phonebook = {'titu':9423,'dadu':9422,'giri':9326}
inverted_phonebook=invert(phonebook)
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
inverted_phonebook=invert(phonebook)
NameError: name 'invert' is not defined
>>def invert(table):
index={}
for key in table.key():
value=table[key]
if not index.has_key(value):
index[value]=[]
index[value].append(key)
return index
************************************************** **********************

Mar 23 '07 #1
5 3513
En Fri, 23 Mar 2007 04:25:52 -0300, sandeep patil <sa*******@gmail.com>
escribió:
i have install python on window xp os.
C:/program files/python

i have done print program it working but .py can't working
help me to how i will execute this file this file where i will save
it.
path execution how .
tell me about any envorment veriable in python to set before python
editor run,it path. etc
You don't need to set any environment variable to run Python. (Perhaps
PYTHONPATH, but *only* if you put modules into non standard places)
>>>import posix

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
import posix
ImportError: No module named posix
That's ok: there is no module named "posix" on Windows, it is only
available on Unix systems.

I've rearranged a bit your example. Write the following into a file named
test.py - use whatever editor you like (even notepad):

---begin file test.py---
def invert(table):
index = {}
for key in table:
value = table[key]
if not index.has_key(value):
index[value] = []
index[value].append(key)
return index

phonebook = {'sandeep':9325, 'amit':9822, 'anand':9890, 'titu': 9325}
print "Phonebook", phonebook

inverted_phonebook = invert(phonebook)
print "Inverted phonebook", inverted_phonebook
---end file test.py---

Then open a console window, change to the same directory where you saved
test.py, and execute:

python test.py

You should get:

Phonebook {'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
Inverted phonebook {9890: ['anand'], 9325: ['titu', 'sandeep'], 9822:
['amit']}

There are plenty of tutorials about Python. A good book -among others- is
"Dive into Python"; you can buy the book, read it online, or even download
it from http://www.diveintopython.org/

--
Gabriel Genellina

Mar 23 '07 #2
On Mar 23, 7:25 am, "sandeep patil" <san.gu...@gmail.comwrote:
i have install python on window xp os.
C:/program files/python

i have done print program it working but .py can't working
help me to how i will execute this file this file where i will save
it.
path execution how .
tell me about any envorment veriable in python to set before python
editor run,it path. etc
************************************************** **********
>print ' sandeep patil'
sandeep patil
>print ' sandeep "bhagwan " patil ,msc. java j2ee developer"

SyntaxError: EOL while scanning single-quoted string>>print ' sandeep "bhagwan " patil ,msc. java j2ee developer'

sandeep "bhagwan " patil ,msc. java j2ee developer
>import posix

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
import posix
ImportError: No module named posix
>phonebook = {'sandeep':9325,'amit':9822,'anand':9890}
phonebook = {'titu':9423,'dadu':9422,'giri':9326}
inverted_phonebook=invert(phonebook)

Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
inverted_phonebook=invert(phonebook)
NameError: name 'invert' is not defined>>def invert(table):

index={}
for key in table.key():
value=table[key]
if not index.has_key(value):
index[value]=[]
index[value].append(key)
return index
************************************************** **********************
Hi Sandeep.

As you are working with Python on Windows, I would suggest that you
install the Python for Windows extensions from here:

http://sourceforge.net/project/showf...group_id=78018

It includes a very good application called PythonWin. Once installed,
PythonWin will be available under Python in your Start menu.

If you run PythonWin, File/New gives you the option to create a new
Python script. To begin with, you can save into the Lib folder of your
Python installation (probably C:\Python25\Lib). I usually add my
initials at the front of the script name to differentiate my scripts
from the standard ones if I put stuff in Lib.

You should be able edit your PYTHONPATH variable in PythonWin - see
the Tools options (though, now I look, my installation actually has a
bug in this function), or alternatively, you can add a folder to your
PYTHONPATH environment variable in RegEdit (if you know what you're
doing).

I hope this helps.

J.

Mar 23 '07 #3
That should have been:

"You should be able edit your PYTHONPATH variable (should you need
to)..."

Gabiel is right, it's not usually required.

Mar 23 '07 #4
i have written this program but i have gott following error,
in anather proram "indentation error" sir how i will indent in my
editor

#test.py
>>def invert(table):
index=()
for key in table:
value=table[key]
if not index.has_key(value):
index[value]=[]
index[value].append(key)
return index

>>phonebook = {'sandeep':9325, 'amit':9822, 'anand':9890, 'titu': 9325}
phonebook
{'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
>>print phonebook
{'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
>>inverted_phonebook = invert(phonebook)
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
inverted_phonebook = invert(phonebook)
File "<pyshell#9>", line 5, in invert
if not index.has_key(value):
AttributeError: 'tuple' object has no attribute 'has_key'
>>interted_phonebook= invert(phonebook)
Traceback (most recent call last):
File "<pyshell#14>", line 1, in <module>
interted_phonebook= invert(phonebook)
File "<pyshell#9>", line 5, in invert
if not index.has_key(value):
AttributeError: 'tuple' object has no attribute 'has_key'
>>>
Mar 26 '07 #5

On Mar 26, 2007, at 7:00 AM, sandeep patil wrote:
i have written this program but i have gott following error,
in anather proram "indentation error" sir how i will indent in my
editor

#test.py
>>>def invert(table):
index=()
for key in table:
value=table[key]
if not index.has_key(value):
index[value]=[]
index[value].append(key)
return index

>>>phonebook = {'sandeep':9325, 'amit':9822, 'anand':9890, 'titu':
9325}
phonebook
{'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
>>>print phonebook
{'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
>>>inverted_phonebook = invert(phonebook)

Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
inverted_phonebook = invert(phonebook)
File "<pyshell#9>", line 5, in invert
if not index.has_key(value):
AttributeError: 'tuple' object has no attribute 'has_key'
If you define index as a dict instead of a tuple, you'll stop getting
that error -- but I'm afraid it still won't do what you want. Are
you trying to get a phonebook in which the values of the original
phonebook are the keys of the new one -- and the values are lists
(both 'sandeep' and 'titu' have the same number)? If so, try this:

def invert(table):
index=dict()
for k,v in table.items():
if index.has_key(v):
index[v].append(k)
else:
index[v] = [k]
return index

You had mentioned something about indentation error... If you'll
look at your definition of invert(), you can see that 'return index'
is inside the for loop -- which would cause a return before the
second time through the for loop. By dedenting (is that a word?) so
'return' falls directly below 'for', the for loop would have been
able to run to completion before returning.

Hope this helps,
Michael

---

Our network was brought down by a biscuit??? --Steven D'Aprano

Mar 26 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bill ramsay | last post by:
Dear all. I am using an existing hodge-podge of an application that runs on top of an Access database. This application dials up customer equipment, handshakes then downloads/uploads various...
17
by: Paul Rubin | last post by:
Dumb question from a Windows ignoramus: I find myself needing to write a Python app (call it myapp.py) that uses tkinter, which as it happens has to be used under (ugh) Windows. That's Windows...
217
by: gyromagnetic | last post by:
The following url points to an article written by Damian Conway entitled "Ten Essential Development Practices": http://www.perl.com/pub/a/2005/07/14/bestpractices.html Althought the article has...
4
by: mitsura | last post by:
Hi, I am writing a program in Python and I am using wx.Python for the GUI. I have no prior GUI and Python experience so that's why I turn to the specialists for aid. Basically, my app is a...
30
by: bblais | last post by:
Hello, Let me start by saying that I am coming from a background using Matlab (or Octave), and C++. I am going to outline the basic nuts-and-bolts of how I work in these languages, and ask for...
2
by: André | last post by:
Short description: Using a wxPython based app, I would like to take a python script in an editor window, invoke the python interpreter and use another window as stdin/stdout/stderr. Based on...
7
by: André | last post by:
First, an apology: I realise that I don't know enough about what I am asking to make sure to use the proper language to phrase my question. I would like to use a browser (e.g. Firefox) as a...
122
by: Edward Diener No Spam | last post by:
The definition of a component model I use below is a class which allows properties, methods, and events in a structured way which can be recognized, usually through some form of introspection...
12
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed...
7
by: greg | last post by:
Thomas Philips wrote: Have a look in /Library/Frameworks/Python.framework/Versions/2.5 You can't -- this feature only exists in the Search window, which is a different kind of window...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.