473,657 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange problem when running python code

Hi everybody

I've been writing my very first application in Python and everything is
running smoothly, except for a strange problem that pops up every once
in a while. I'm sure is the kind
of newbie thing every seasoned programmer knows.

Sometimes a receive strange Syntax Errors from parts of code that
worked perfectly minutes ago. What's even more puzzling is that those
errors are pointed to another part of the module when I do some random,
innofensive changes in the code (like inserting a line or deleting some
comments). Sometimes those changes are enough to make the error
dissapear.

Could it be that python has found a real error but is failing to tell
me where it is?

Apr 4 '06 #1
12 1500
For certain errors like Syntax Errors, you'll get a much more helpful
response if you post some actual code. Strip it down if you have to,
but make sure we can reproduce the errors.

--
Brian Beck
Adventurer of the First Order

Apr 4 '06 #2
ishtar2020 wrote:
Hi everybody

I've been writing my very first application in Python and everything is
running smoothly, except for a strange problem that pops up every once
in a while. I'm sure is the kind
of newbie thing every seasoned programmer knows.

Sometimes a receive strange Syntax Errors from parts of code that
worked perfectly minutes ago. What's even more puzzling is that those
errors are pointed to another part of the module when I do some random,
innofensive changes in the code (like inserting a line or deleting some
comments). Sometimes those changes are enough to make the error
dissapear.

Could it be that python has found a real error but is failing to tell
me where it is?


I recently had quite a hassle with an indentation problem, so you might
want to check on your whitespace.

Apr 4 '06 #3
ishtar2020 <is********@hot mail.com> wrote:
I've been writing my very first application in Python and everything is
running smoothly, except for a strange problem that pops up every once
in a while. I'm sure is the kind
of newbie thing every seasoned programmer knows.


Nobody here has a crystal ball. Please post your code, tell us what
changes you made, and cut-and-paste the entire error message and the
associated stack trace.
Apr 4 '06 #4
"ishtar2020 " wrote:
Sometimes a receive strange Syntax Errors from parts of code that
worked perfectly minutes ago. What's even more puzzling is that those
errors are pointed to another part of the module when I do some random,
innofensive changes in the code (like inserting a line or deleting some
comments). Sometimes those changes are enough to make the error
dissapear.


Python 2.4.1 has a bug where this can happen if you're 1) using coding
directives, and 2) your module is relatively large.

I suggest upgrading to 2.4.3.

</F>

Apr 4 '06 #5
I must add, when the python interpreter displays the traceback, with
the line that is producing the error, it doesn't look like the one I
got in the code.

This is the line where the interpreter finds the error

if text.list[i].toString() in limits:list)): <- Here is where
the error is found, but this line is not on my file

SyntaxError: invalid syntax

And this is the line I got on the file, looks like the interpreter is
mixing the second sentence with the end of the first one:

for i in range(self.init ialPositionl+1, len(text.list)) :
if text.list[i].toString() in limits:
self.finalPosit ion=i
break

It's quite puzzling. And if I change some lousy thing, like inserting a
newline between the sentences, the interpreter will find another error
somewhere else, even when that
part of the code was working flawlessly in previous runs

Apr 4 '06 #6
Roy Smith wrote:
ishtar2020 <is********@hot mail.com> wrote:
I've been writing my very first application in Python and everything is
running smoothly, except for a strange problem that pops up every once
in a while. I'm sure is the kind
of newbie thing every seasoned programmer knows.


Nobody here has a crystal ball. Please post your code, tell us what
changes you made, and cut-and-paste the entire error message and the
associated stack trace.


Speak for yourself, Mr. I-Have-No-Crystal-Ball. Besides, any lummox knows
that crystal balls are for seeing the future, not for mind-reading. No, to
do proper mind reading you need youself a pointy hat and (preferably) a
deck of cards.

Sorry, weird day at work. Had to vent.
--
Steve Juranich
Tucson, AZ
USA

Apr 4 '06 #7
ishtar2020 wrote:
Hi everybody

I've been writing my very first application in Python and everything is
running smoothly, except for a strange problem that pops up every once
in a while. I'm sure is the kind
of newbie thing every seasoned programmer knows.

Sometimes a receive strange Syntax Errors from parts of code that
worked perfectly minutes ago. What's even more puzzling is that those
errors are pointed to another part of the module when I do some random,
innofensive changes in the code (like inserting a line or deleting some
comments). Sometimes those changes are enough to make the error
dissapear.

Could it be that python has found a real error but is failing to tell
me where it is?


I don't mean to accuse you or to start a tab v. non-tab war (is tab v.
non-tab a holy war?, it should be because tabs are so damn useful for
formatting and getting everything just-right), but don't use tabs if you
are using them. Here are the reasons: 1. they personally annoy me. 2.
you can't see the damn things (hence the basis for why they are so
annoying). "Tab" comes from the root for the Greek for "table" (or is it
the other way around?, or is it Latin? or Arabic? or Hebrew?). Thus,
tabs should be reserved for thier god-given intended purpose, which is
tab-delimited tables, where a parser can easily separate by them.
Internal, and hence annoying, tabs should not be used elsewhere because
it screws everything up. For example, here is a tab-delimited parser
written in python
table = []
for line in tab_delimited_t able:
table.append(li ne.split('\t'))
Man that was easy! Now, when people put annoying tabs everywhere, to get
their indent just-so, then it totally screws everything up, including
this parser, which was designed for tables delimited by tabs--because
that is the tab's special purpose.

There is one exception however. Its called the tab-space-tab approach.
If you are using tabs to indent your code, then always put at least one
space between tabs. Never put two tabs together. This helps the editor
to display your code correctly.

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
Apr 4 '06 #8
On 04/04/2006-12:01PM, ishtar2020 wrote:
This is the line where the interpreter finds the error

if text.list[i].toString() in limits:list)): <- Here is where


That line has two extra close parens before the :

Can you show the traceback?

Apr 4 '06 #9
Are U Using any IDE for Python?
If yes then check out the setting and make sure that u are running same
code.

Apr 5 '06 #10

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

Similar topics

6
1701
by: KefX | last post by:
Hi guys! I'm still a bit of a Python newbie, but regardless I decided to embed Python into a plugin for a freeware (closed-source) Windows music program called Jeskola Buzz. (Man, I can't believe how many people keep telling me "Extend Python instead!" when clearly I can't do that in this case. If somebody here tells me this, I will explode in an appropriately gory fashion.) It's a great program, and it works mainly on plugins other people...
2
1654
by: simon place | last post by:
while playing about with inheriting from list to be able to cache macro properties i noticed this, the rate of summing a list seems to be over linear? its nearly 3 times faster to sum the sums of smaller lists? from time import clock l=range(0,1000000)
1
3172
by: Craig Ringer | last post by:
Hi folks I'm a bit of a newbie here, though I've tried to appropriately research this issue before posting. I've found a lot of questions, a few answers that don't really answer quite what I'm looking for, but nothing that really solves or explains all this. I'll admit to being stumped, hence my question here. I'm also trying to make this post as clear and detailed as possible. Unfortunately, that means it's come out like a book. I...
4
1457
by: Tomasz Lisowski | last post by:
Hi, We are distributing our Python application as the short main script (.py file) and a set of modules compiled to the .pyc files. So far, we have always treated .pyc files as portable between platforms, but recently we have discovered an annoying problem. In a module, there is the following code fragment: Deg2Rad = math.pi/180.0 angleEPS = 0.5
6
3744
by: cournape | last post by:
Hi there, I have some scientific application written in python. There is a good deal of list processing, but also some "simple" computation such as basic linear algebra involved. I would like to speed things up implementing some of the functions in C. So I need profiling. I first tried to use the default python profiler, but profiling my application multiplies the execution time by a factor between 10 and 100 ! So I decided to give a...
3
1621
by: jdonnell | last post by:
When I run this code on windows it runs quickly (about a second per image) but when I run it on linux it runs very very slowly (10+ seconds per image). Is this a bug or am I missing something? On windows I tried 2.4.2 and 2.4.1 on linux i'm running 2.4.1 print 'starting' f = urllib2.urlopen('http://site.heavenlytreasures.com/images/e6115.jpg') outfile = open('e6115.jpg', 'wb') outfile.write(f.read())
5
3103
by: Ian | last post by:
Hi everyone, I have found some bizarre (to me...!) behaviour of the Form_Activate function. I have a form which has a button control used to close the form and a subform with a datasheet view showing a list of jobs from the database. When the main form loses focus and the user clicks the 'Close' button, I kept receiving error 2585 (This action cannot be carried out whilst processing a form or report event). This was tracked down to...
2
3732
by: dwelch91 | last post by:
Hi, c.l.p.'ers- I am having a problem with the import of xml.parsers.expat that has gotten me completely stumped. I have two programs, one a PyQt program and one a command line (text) program that both eventually call the same code that imports xml.parsers.expat. Both give me different results... The code that gets called is (print statements have been added for debugging):
4
1217
by: kj | last post by:
I'm running into a strange seg fault with the module cjson. The strange part is that it does not occur when I run the code under Emacs' Pydb. Here's an example: import sys, cjson d1 = {'a': 1, 'b': 2, 'c': 3}
0
8324
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.