Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 21st, 2003, 06:12 PM
kawika kawika is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 17 kawika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Break class out from main file

Hi,

I am tweaking Ensims skin file structure and I want to do two things:

1. Remove the class from the main file and put it in it's own file and import it.

2. All def's in the class in their own files also.

So in the end there would be 3 files; main.py, class.py, and class_def.py. Below is the main file minus most of the main imports and class def's. I put one in there for example. Any help is appreciated.

Code:
#main.py
import skin
class Skin(skin.SkinBase):
    def appliance_navbar(self):
        filterobj = skin.UnhiddenServicesFilter(self.REQUEST)
        dict_to_menu()

Reply With Quote
  #2  
Old September 21st, 2003, 07:15 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 68
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Hey kawika,

Sorry maybe i missed this but what was the question? I gathered your making some changes to a program but other than that i'm lost.. you've seperated the classes and functions into files and you wanted somone to?

Post the whole thing (zipped or something) i'd be happy to take a look just out of interest but i'm just not sure what you're looking for

Have fun,
Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #3  
Old September 21st, 2003, 07:34 PM
kawika kawika is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 17 kawika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hey Netytan, thanks for responding.

There is currently one file, main.py which contains all the code above.

What I want to do is remove the class definition and all the defs in the class from main.py and put them into seperate files.

So there would be three files (attempted detail below), main.py which calls the class and the class file that calls a class def, and the finally the def file. Hope that makes sense.

I successfully seperated the entire class from main.py but when I try to put one of the class defs into their own file it chokes.

Thanks for your help.
Kawika

Code:
#main.py
import skin
import Skin


#Skin.py
class Skin(skin.SkinBase):
import def_appliance # this doesn't work.


#def_appliance.py
def appliance_navbar(self):
        filterobj = skin.UnhiddenServicesFilter(self.REQUEST)
        dict_to_menu()

Reply With Quote
  #4  
Old September 21st, 2003, 08:21 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 68
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Ok i think i get you,

just a few questions.. are the 3 comented code blocks below the 3 files? also, your saying it chokes, what error message are you getting here, it might help us figure out whats wrong. It might also help if you could attach the actual Python files as a zip so i can give it ago myself?

then just one from me, why is it so impotant that they are in seperate files?

Mark.

Reply With Quote
  #5  
Old September 22nd, 2003, 10:51 AM
percivall percivall is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 133 percivall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 10
It wouldn't make sense to remove a definition of a member method in a class and place it in another file. Well, you can do something similar, but I can't see the why of it.

What you'd have to do to make it work similarly would be to import the method, then bind the method data object to a class variable name.

This won't work well if you need to access class or instance attributes though, so it's mostly useless, since that's the only reason to have class/instance methods to begin with.

Reply With Quote
  #6  
Old September 22nd, 2003, 10:57 AM
kawika kawika is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 17 kawika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi, yeah I know it makes no sense but the file I'm working with contains lot's of funcations with html and I'm trying to write an editor for it. With all the code and html combined it would be easier if the files were seperated so my editor could easily know what it's dealing with and I could make incremental upgrades without replacing the entire file.

Do you have an example of something like this or a link to an example?

For now I'll just have to run a parsing routine on the 60K file everytime I want to edit some html in a class function. Very slow and ugly but if that's all I can do then oh well.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Break class out from main file

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap