473,767 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extreme n00b question

hi all,

a python n00b, so please bear with me. i have a simple question:

i generally name python sources as a-simple-python-example.py. when i
try to import a module named as above, i (obviously) get tracebacks
from python interpreter.

is there a way to continue naming python sources as above, and still
use it as python modules ? i can ofcourse change the name to
'a_simple_pytho n_example.py', which then works.

thank you
kind regards
anupam

Jul 26 '05 #1
3 1531
Anupam Kapoor wrote:
is there a way to continue naming python sources as above, and still
use it as python modules ? i can ofcourse change the name to
'a_simple_pytho n_example.py', which then works.


Something like

a_simple_python _example = __import__('a-simple-python-example')

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
If the sky should fall, hold up your hands.
-- (a Spanish proverb)
Jul 26 '05 #2
,----
| Something like
| a_simple_python _example = __import__('a-simple-python-example')
`----

thanks ! that works.

kind regards
anupam

Jul 27 '05 #3
Anupam Kapoor wrote:
i generally name python sources as a-simple-python-example.py. when i
try to import a module named as above, i (obviously) get tracebacks
from python interpreter.

is there a way to continue naming python sources as above, and still
use it as python modules ? i can ofcourse change the name to
'a_simple_pytho n_example.py', which then works.


Your question has already been answered, but I think your life (and that
of anyone trying to use your code) would probably be easier if you
switched to underscores.
--
Michael Hoffman
Jul 27 '05 #4

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

Similar topics

1
1786
by: Matt | last post by:
I'd like to overwrite just one line of a binary file, based on a position set by seek(). Is there no way to do this? As far as I can tell I need to read the whole file, change the line, and write it all back out. Not exactly easy on the memory, but I see no other solution. so far: patchme.seek(offset) patchme.write(a2b_hex(edit)) # the data is in hex first patchme.close
0
2269
by: MarionEll | last post by:
--------------------------------------------------------- ************* Call for Participation ************** ************ Late Breaking News ************* *********** Extreme Markup Languages 2003 ************ --------------------------------------------------------- The regular (peer reviewed) part of the Extreme 2003 program has been scheduled. As usual, we have reserved a few slots on the Extreme program for...
1
1544
by: newgenre | last post by:
I am using a pre-built package of code for my site, which is called EasyDisc. All it does is it creates an interactive forum on your site, like any forum you see anywhere. I am having a problem getting started as I am new to .NET and sql. The app, once unzipped, tells me to "Make note of your SQL server name, username, password, database name. You need to supply these info. later." My problem is I don't know where to find out that info....
0
1063
by: Tommie Usdin | last post by:
The program for Extreme Markup Languages 2006 is now available at: http://www.extrememarkup.com/extreme/2006/e06-at-a-glance.html Topics at Extreme 2006 will range from XSLT, RDF, XPath, Ropic Maps, XML schema languages, overlap, SGML, and metadata to design and promulgation of tag sets. Presentations that may be of particular interest to readers of comp.text. xml include:
4
10144
by: onefry | last post by:
Hey I have this prog that i'm working on, starting my first c++ class and kind of a n00b to programming here it is #include <iostream> #include <cstdlib> using namespace std;
6
1506
by: Charles | last post by:
I am learning from the Accelerated C++ book. The following example doesn't work and I don't know why: #include <iostream> #include <string> int main () { const std::string exclam = "!"; const std::string message = "Hello" + ", world" + exclam; return 0; }
3
1327
by: rtlshred | last post by:
Hello I have just, just started C++ programing. the complier I am using is Dev C++ Here is my question: Once I have written some code, How do I run the program and see the output?
2
4230
by: benwah1983 | last post by:
Greetings, Here is my problem: The following code shows a div with two small nested divs (images with a title), then the div is closed. Another one opens and a "random text" is displayed. <div style="width: 500px;"> <div style="float: left; padding: 20px;"> Image Title 1<br/> <img src="test.jpg"/> </div> <div style="float: left; padding: 20px;">
4
1268
by: ig | last post by:
First off, I'm a python n00b, so feel free to comment on anything if I'm doing it "the wrong way." I'm building a discrete event simulation tool. I wanted to use coroutines. However, I want to know if there's any way to hide a yield statement. I have a class that I'd like to look like this: class Pinger(Actor): def go(self): success = True
0
9571
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10168
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
10009
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9838
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...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
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();...
1
3929
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
3
2806
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.