473,587 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

import and global namespace

I'd like a module than I'm importing to be able to use objects in the
global namespace into which it's been imported. is there a way to do
that?

thanks,
nate

Jul 11 '06 #1
2 1360
nate a écrit :
I'd like a module than I'm importing to be able to use objects in the
global namespace into which it's been imported. is there a way to do
that?
It's a very bad idea. Instead of asking how to implement a bad solution,
tell us about the real problem.

NB : FWIW, the clean solution probably involve a class...
Jul 12 '06 #2
Dennis Lee Bieber wrote:
On Wed, 12 Jul 2006 02:48:44 +0200, Bruno Desthuilliers
<bd************ *****@free.quel quepart.frdecla imed the following in
comp.lang.pytho n:

>>nate a écrit :
>>>I'd like a module than I'm importing to be able to use objects in the
global namespace into which it's been imported. is there a way to do
that?

<snip>
>>NB : FWIW, the clean solution probably involve a class...


Or a common module that both (all) import...
I'm afraid this would be as messy. Having one module depending on
implicits external names is a good way to spaghetti code.

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom. gro'.split('@')])"
Jul 12 '06 #3

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

Similar topics

9
2932
by: Paul Rubin | last post by:
That's what the Python style guides advise. They don't seem to like def frob(x): import re if re.search('sdfxyz', x): ... instead preferring that you pollute your module's global namespace with the names of all your imports. What's the point of that? It gets worse when you want to do something like
5
2148
by: Pekka Niiranen | last post by:
Hi there, I have two scripts. The first "main.py" sets some variables and then imports another called "gen.py". The idea is to provide "main.py" that defines some paths, variables etc. without using Windows environment variables. Various other "hackers" will make additional Python scripts (subroutines) like "gen.py" that utilize variables...
1
4062
by: D. Shane Fowlkes | last post by:
Tw part question: 1 - Is it <% @Import Namespace..... or <%@ Import Namespace... ? I'm seeing it both ways in a book (but I think one is a typo. My pages don't seem to care which it is. Or do they?....see below 2 - I'm trying to import the namespaces of System.Data and System.Data.SQLClient in the global.asax file so I don't have to do...
2
1807
by: Shapper | last post by:
Hello, In the main root of my web site together with my aspx and aspx.vb files I have the file global.vb. This file has a class with all the functions which are used in many aspx.vb files and it is like this: Imports System Namespace Global
2
22493
by: Carmit | last post by:
Hi, I'm trying to build a proxy for this webservice: http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/EndTransactionLLSRQ.wsdl I'm getting the following error: Error: Unable to import binding 'EndTransactionSoapBinding' from namespace 'http s://webservices.sabre.com/websvc'.
16
3096
by: didier.doussaud | last post by:
I have a stange side effect in my project : in my project I need to write "gobal" to use global symbol : .... import math .... def f() : global math # necessary ?????? else next line generate an error message ?????
23
6409
by: Shane Hathaway | last post by:
Here's a heretical idea. I'd like a way to import modules at the point where I need the functionality, rather than remember to import ahead of time. This might eliminate a step in my coding process. Currently, my process is I change code and later scan my changes to make matching changes to the import statements. The scan step is error...
49
3907
by: Martin Unsal | last post by:
I'm using Python for what is becoming a sizeable project and I'm already running into problems organizing code and importing packages. I feel like the Python package system, in particular the isomorphism between filesystem and namespace, doesn't seem very well suited for big projects. However, I might not really understand the Pythonic way....
16
1411
by: Stef Mientki | last post by:
This might be a very weird construction, but it's the most easy way in translating another language into Python (for simulation). Although it works, I like to know if this a valid construction: I've defined a class, like this, attaching a not yet defined global to itself class T6963_device (tDevice): def __init__ (self):
4
1087
by: Peter Teuben | last post by:
if I define a simple string code, with the following contents: import math def foo(x): return math.sqrt(x) and i run it using exec(code) in python, math is not known. But when I recode the string as: def foo(x):
0
7918
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...
0
8206
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. ...
0
8220
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...
0
6621
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...
1
5713
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...
0
5392
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...
0
3840
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...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.