Python Forum
class needs to refer a different class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
class needs to refer a different class
#21
(Jul-21-2021, 03:14 PM)Skaperen Wrote: the intention is to provide an instance that is appropriate for the particular file. if an instance of io.IOBase is appropriate, that's what should be returned. but, an instance of this class may be appropriate.

Sounds like a good case for a factory.
Reply
#22
(Jul-18-2021, 01:57 AM)Skaperen Wrote: this is big, so i am not going to post it here. instead, you get a link:
http://ipal.net/python/zopen.py

Yes, there's a lot of code there and it's not too helpful. A really good way to describe in code what you're wanting to do is to write a test. Why? It helps you clarify what you're trying to achieve and to focus on one small part of the problem. "Programming by wishful thinking" is basically what we're doing when we do test-driven development, for those reasons.

Also, when you do want to share your project with people, why provide these individual links, rather than just one link to a repository? That would make it easier for people to get everything and play around with it.
Reply
#23
here is a script i have made into a command named zhash on my laptop that uses zopen.
http://ipal.net/python/zhash.py
this command hashes each file in an uncompressed form even if it is compressed in the file system as long as the name shows the compression stack. zhash also uses ftrgen (a generator that flattens a file tree).
http://ipal.net/python/ftrgen.py
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  is ValueError a class? Skaperen 11 2,455 Mar-29-2023, 02:25 AM
Last Post: Skaperen
  extracting a function/class/method from code Skaperen 5 2,154 Mar-30-2022, 12:13 AM
Last Post: Skaperen
  first class objects Skaperen 0 924 Jan-22-2022, 02:53 AM
Last Post: Skaperen
  returning a different class Skaperen 4 2,069 Oct-20-2021, 12:51 AM
Last Post: Skaperen
  getting my head arounnd __enter__() for my new class Skaperen 5 2,470 Nov-30-2020, 09:46 AM
Last Post: Gribouillis
  find the class for indexed counting Skaperen 4 1,951 Sep-29-2020, 03:26 AM
Last Post: Skaperen
  namespaces when defining a class Skaperen 3 2,076 Jul-03-2020, 06:34 PM
Last Post: Gribouillis
  a file-like class implementation Skaperen 2 1,988 Apr-22-2020, 02:59 AM
Last Post: Skaperen
  making a generator class? Skaperen 2 2,031 Apr-01-2020, 12:34 AM
Last Post: Skaperen
  single-instance class Skaperen 3 2,448 Mar-05-2020, 12:47 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020